texts:
I am trying to get my head around the drupal 7 render() function but there is something I can't get straight.

The data source that I want to render looks like this:

Array
(
    [id] => 3315539862007
    [name] => Some Name
    [picture] => some-facebook-image.jpg
    [link] => http://www.facebook.com/some-page

I pass it to a $block['content'] like this (I also tried changing '#children' to '#element', but with no success):

$block['content'] = array(
  '#theme' => 'opengraph_company',
  '#children' => $data
);

but inside my custom theming function the data that is passed looks really weird

function theme_opengraph_company($variables) {
  $element = $variables['element'];

  return 'hello';
}

if I debug the $variables inside the theming function I get something like this

Array
(
    [element] => Array
        (
            [#theme] => opengraph_company
            [#children] => Array
                (
                    [id] => 3315539862007
                    [name] => Some Name

which to me looks really weird. The MYMODULE_theme function looks like this

function opengraph_theme() {
  return array(
      'opengraph_company' => array(
      'render element' => 'element',
    ),
  );
}

I would expect access to the data based to the theming function to easier, something like

function theme_opengraph_company($variables) {
  $element = $variables['element'];

  return $element['name'];
}

Am I passing the parameters wrong to the theming function?


texts: When to use Flag's submodule flag_actions instead of Rules Actions?

texts:
If you enable the Flag module, but not its submodule flag_actions (with short description "Execute actions on Flag events."), and you navigate to admin/structure/flags, then near the bottom it shows a line like so:

Flagging an item may trigger actions. However, you don't have the Flag actions module enabled, so you won't be able to enjoy this feature.

If you do enable submodule flag_actions, then this line near the bottom becomes like so (whereas actions becomes an hyperlink to /admin/structure/flags/actions, which also corresponds to the extra tab "Actions" you get after enable of this submodule):

Flagging an item may trigger actions.

I'm familiar with "Actions" (included in core as of Drupal 6), and I'm also familiar with Rules Actions. And in the Community Documentation it says:

Flags aren't just for creating passive "My bookmarks" lists. Flagging a node can fire some actions. This module supports the Actions module (Actions is included in core as of Drupal 6), and the more powerful Rules module.
Simple Actions that could be triggered by Flags:

automatically unpublish a node that has been flagged as "spam";
sending an email to the site administrator when a node is flagged as "spam" more than 3 times;
automatically flagging a newly-updated node with a "needs review" flag.

All this looks, sounds and smells very similar to using Rules Actions which you can do if you have Rules enabled. Nevertheless I wonder if there are any situations, or usecases, where using the Flag's submodule flag_actions would be more appropriate as compared to using Rules?


texts: Managed to delete Event_Calendar_Status and cannot reinstate

texts:
When trying to get rid of notification emails every time I create a calendar event, I have managed to delete the ?built-in? event calendar status term. I have tried to reinstate it but machine will not allow the same name as original. It's causing an undefined index Notice which will not now let me save any new events.

Have not got much stuff on the site yet, so may have to disable, uninstall and reinstall the calendar module?

This appears when creating new calendar event:
Notice: Undefined index: event_calendar_status in event_calendar_form_alter() (line 293 of web1/user47631/website/sites/all/modules/ event_calendar/event_calendar.module)

Grateful for any help or suggestions...

Cynthia


texts: @font-your-face don't work when 'Aggregate and compress CSS files' is enabled

texts:
I added font using @font-your-face module and everything works just fine except when 'Aggregate and compress CSS files' is enabled. When I enable css aggregation and compression, whole website use some default font instead imported font in @font-your-face.

Does anyone have problem like this? Some suggestions how to resolve this?


texts:
I'm building a index view to use as search. I'm grouping the results by a term field and everything works fine. What I want to do is add a count after the group title to show how many results that exists with this term.

Can't find a way to do this in drupal 8 so I'm asking you.
I've google for half a day without finding anything.


texts: How do you make sortable tables with a pager with data from a custom table?

texts:
For Drupal 6 you could do something like this:

$header = array(
  array('data' => t('Order id'), 'field' => 'order_id'),
  ...
  array('data' => t('Transaction time'), 'field' => 'payment_time', 'sort' => 'desc'),
);
$sql = "...";
$sql .= tablesort_sql($header);
$limit = 25;
$result = pager_query($sql, $limit);
...

I took a look and for drupal 7 and both pager_query and tablesort_sql is now gone. It seems that instead the PagerDefault class can be used to create a pager query using DBTNG. I wasn't able to find any clues on a simple API for attaching a sortable table to the query like it is done in Drupal 6.

So how do you create a sortable table with a pager pulling data from a custom table?


texts: Fatal error: Unsupported operand types in field.info.inc

texts:
I'm cloning my client's drupal 7.15 site from online to my localhost. I received a copy of site folder and a copy of a sql dump file. I installed them into my localhost.

When I run the site, firstly I encountered the error:

  Fetal error: Class name must be a valid object or a string in
  C:\xampp\htdocs\mysite\includes\common.inc on line 7679

But the error went away when I did clear all cache tables manually via phpMyAdmin.
Unfortunately, the next error appeared.

  Fatal error: Unsupported operand types in
  C:\xampp\htdocs\mysite\modules\field\field.info.inc on line 294

[Edit]
I installed Drush and navigated to my site in Drush command line, but I could not run commands except "drush" because of that error.

  C:\xampp\htdocs\mysite>drush user-login
  Drush command terminated abnormally due to an unrecoverable error.       [error]

  Error: Unsupported operand types in
  C:\xampp\htdocs\mysite\modules\field\field.info.inc, line 294

  C:\xampp\htdocs\mysite>drush status
  Drush command terminated abnormally due to an unrecoverable error.       [error]

  Error: Unsupported operand types in
  C:\xampp\htdocs\mysite\modules\field\field.info.inc, line 294

  C:\xampp\htdocs\mysite>drush cache-clear
  Drush command terminated abnormally due to an unrecoverable error.       [error]

  Error: Unsupported operand types in
  C:\xampp\htdocs\mysite\modules\field\field.info.inc, line 294

When I traced into field.info.inc, I found that $instance['settings'] ( of the first parameter of _field_info_prepare_instance ) is missing for the field field_tags. Thus, the "+=" operation for arrays failed.

print $instance
Array
(
    [id] => 5
    [field_id] => 3
    [field_name] => field_tags
    [entity_type] => node
    [bundle] => article
    [deleted] => 0
)
print $instance["settings"]

****************
print field_info_instance_settings() call on taxonomy_term_reference
Array
(
    [user_register_form] =>
)


texts: Output the "Body" field with markup using Views PHP to be used in Views Datasource (JSON)

texts:
We are creating an API using Views/Views Datasource and we want to output the Body field with markup already in the field not plain text. How can we do this?
This Views_PHP approach just outputs the standard Body field as text.

$nid = $row->nid;
$node = node_load($nid);
$display = array('type' => 'ugc');
$output = field_view_field('node', $node, 'body', $display);
print render($output);

On the example below the @papermill should be a link if this was rendered on the front end.


texts:
I am trying to print the webform submission label and value from tokens in confirmation email. The problem is that the label of the form element is not appearing, only the value.
Tried with:

[webform_submission:values:email]
[webform_submission:values:email:withlabel]
[webform_submission:values:format:html]

When I print all the elements with [webform_submission:values] , I am able to see also the labels, but the formatting is not so good, so I want to print the values line by line.


texts: Type hinting - which is better, UserInterface or AccountInterface?

texts:
Recently I've finally begun shifting my focus from D7 to D8, and I'm converting a site over to D8. In D7, I type-hinted my account objects as \stdClass, since they were not members of any class. However in D8, they are now members of the User class.

That said, I'm finding in some code on the net that people are typehinting as Drupal\Core\Session\AccountInterface, and in other places as Drupal\user\UserInterface. How should we be determining which one to use for our typehints, and what is the difference between the two types of objects?


texts: Drush rsync command failed: No such file or directory

texts:
I am new to use Drush.

this following is my .drushrc.php file

$aliases['server'] = array (
  'remote-host' => '162.243.78.240',
  'remote-user' => 'root',
);
$aliases["dxb"] = array (
  '#name' => 'dxb',
  'root' => '/var/www/dev/daxuebao',
);

I try to use this following command to sync local site to remote site

$ drush rsync @self @dxb

But it alert me:

rsync: mkdir "/var/www/dev/daxuebao" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at /SourceCache/rsync/rsync-42/rsync/main.c(544) [receiver=2.6.9]
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
Could not rsync from /Users/tangmonk/Sites/drupal/daxuebao// to      [error]
/var/www/dev/daxuebao/

It seems directory /var/www/dev/daxuebao do not exist, so I try to mkdir to my server :

$ mkdir /var/www/dev/daxuebao

The I type $ drush rsync @self @dxb again, But still above problem.
How to solved it?


texts: How to generate an unique code for every node

texts:
I have a social article website; I created a content type named Article.
When a user creates an article, I want to generate a code shown to the user. This code should be saved in the database because users can return to this article with this code.
It's important to build a views with this code.

I think I must create a CCK field, generate a code (for example hash the node ID or the timestamp of when the node has been create), and show this code in disable a text box for the  author.

Is there any module to do this? What other alternatives do I have?


texts:
I'd like to programmatically execute a view (providing arguments) and get the raw results, without rendering it. Is it possible?

When I use $view->preview('default', $args); it converts the results to HTML. I know I can use $view->result to iterate the raw results, but the custom rendered I'm using for some fields are buggy and give me a WSOD (I have no interest or ability to fix the renderer, it's an edge case :) )

I'm using Views 3 with Drupal 7


texts: Drush stoped working and drush status -v shows Executing: vagrant

texts:
It's important to say that I don't use vagrant!

For some reason this afternoon drush stoped working, it remains stuck. If I run drush status -v I can see it get stuck at Executing: vagrant.
I may have typed something wrong at some point, maybe installed vagrant instead of varnish module but I can't remember and now I can't use drush anymore.

Does anyone have a clue on how to stop drush from trying to execute vagrant silently?


texts: How might I show only the first level of an Exposed Taxonomy Filter in Views?

texts:
In Drupal 7, I have a exposed filter set at first in its hierarchical fashion

with the following structure:

Adjunct
-Adjunct Lecturer
-Adjunct Professor
Chairperson
Clinician
Container
-Director Advising & Student Affairs
-Managing Director TIC
Deans
-Associate Dean Undergraduate Advising Administration
Department Chair
Emeritus
-Associate Professor Emeritus
-Professor Emeritus
Lecturer
-Senior Lecturer
Professor
-Assistant Professor
-Assistant Professor in Residence
-Associate Professor
-Associate Professor in Residence
-Research Scientist & Professor
Speech Pathologist
Visiting
-Visiting Assistant Professor
-Visiting Associate Professor

In the exposed filter, is there a way to expose only the parent (first level) items (Adjunct, Deans, Department Chair, etc)?

Update: Grouping the exposed filter in views did not work (ticket).


texts:
Let's say I have a general content type called "Zoo". A Zoo may have several animals (animals will have a title, image, and description). Now at first, it may seem like I should just have an "Animal" content type and then somehow relate them, but all animals are unique to the zoo. (If two zoos contain a tiger, they will be completely distinct tigers, with their own images/titles/descriptions).

I have a view (already working), that lists the animals. I'd like for the animal titles to link to a page where the animal information (image/title/description) is available.

Because each image (animal) needs it's own respective title and description, and a Zoo may have several images (animals), I've tried to find a way to relate the information, since simply adding fields to the Zoo content type is fruitless.

The closest module I've found is Field Collections, and I'm technically able to reference the information correctly. The problem I'm having with it is, in the view list, I can't figure out how to show the titles of the animals and have them link to somewhere useful.

This "useful" place they link to is what I referred to previously, somewhere with the animal's information (image/title/description).

I know this example seems a little convoluted, and almost like I should use the node reference module. But the real use case requires not having to make separate nodes in separate areas and relating them, but rather making all of them at one time.


texts:
Before submitting a webform a warning is displayed:

  Here are the details you are about to report.

It appears the default text may be altered in:

Home > Administration > Structure  > Webforms > Preview settings

However, can the message be turned off, completely, via the user interface?


texts: Why are there .htaccess and php files in ./sites/default/php/twig

texts: Just wondering, it may be related to cache settings, but why are there lots of php and .htaccess files in the public:// dir?


texts: Language switcher does not display the correct link to the default language path

texts:
I maintain a bilingual English/French website and the Language Switcher block is available on every page to allow the user to switch language. It works except on one particular taxonomy term page and all it's descendants:

When the language is set to English (default), the Language Switcher displays the correct links. English links to the EN page and French links to the FR page.

But when the language is set to French (i.e the user has clicked on French), both English and French options link to the french page (with /fr/rest-of-the-path/).

Any idea where the cause of this behaviour lies in?


texts: Is it possible to show password reset email success in user password page?

texts:
I am completely exhausted trying to find out a solution for this simple problem.

I am intending to put a "Forgot Password" in my Drupal site and wants a confirmation when the form emails the password to the user.

For instance, I go to this link http://www.some.com/user/password for the "Forgot Password" link.

when I enter the username or password, it just doesn't show anything and just redirects to the homepage. I intend to change that and want to show the confirmation that an email has been successfully sent.

Any idea how I can do this?

What I tried

I tried creating a page--user--password.tpl.php but it doesn't allow me to make any changes. I am not sure where the values are coming in the form.


texts:
i'm new in Drupal.
I tried on my site to mount the OAuth2 world but I can't get to the top. The website shows an error that is

Error: Interface 'League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface' not found in include() (line 13 of modules/simple_oauth/src/Repositories/AccessTokenRepository.php).

same applies if I try to manually uninstall the module via ssh with drush pm-uninstall simple_oauth oauth2_server it is impossible:

In Connection.php line 896:
SQLSTATE[42S02]: Base table or view not found: 1146 Table
'site_drupal.oauth2_token' doesn't exist: SELECT "base_table"."id"
AS "id", "base_table"."id" AS "base_table_id" FROM
{oauth2_token} "base_table"
LIMIT 1 OFFSET 0; Array
(
)
In StatementWrapper.php line 116:
SQLSTATE[42S02]: Base table or view not found: 1146 Table
'site_drupal.oauth2_token' doesn't exist

Basically: the site (or the admin section to uninstall the module) cannot be accessed unless this module presents this kind of error, and via ssh I can't figure out how to remove it.
I thank you for any kind of help.


texts:
I can't seem to get any templates to work with my Calendar View Page.

In the view settings, clicking Theme Information reveals some possibles but I've tried them all.

I'm not sure what to name my file to allow it to work as a theme template.

I'm not sure how to theme this Calendar! I only want to add a custom drop down menu above it!


texts: How to mark product if it has already been purchased by current user?

texts:
I have Drupal Commerce shop, that sells products that by their nature are most of the time not useful to buy twice. Exceptions do exist.

So what I want is to show a field or add a class on products page to mark it in very visible way, if current use has at some point bought this product, ie. if this product can be found in current users order history.

I will also want to show this mark in the product listings.

Lastly, I want to tell you that I do have some experience with templates in drupal, but not that much, especially with commerce. I also have Display Suite installed, if the code field way of doing things would be easier.


texts:
I've been reading sites all day trying to figure out what I'm doing wrong or missing, perhaps you can help me. I can't seem to find the right explanation or tutorial.

Situation:

I have a custom View (Content Pane) that generates a Grid of nodes from my Video content type (we'll call it Video Gallery). I created a Page at /videos which includes that Video Gallery content pane in one of the Panels. This is all working very nicely.

I want to be able to filter the results though based on the url, so if they browse to /videos/foo then I'd like to show only the Video nodes which are tagged with the term "foo". This seems to work just fine when I preview the results on the View screen. I've added a Relationship to the Term and added a Contextual Filter on the term id (converted from name). When I type "foo" in the Preview with Contextual Filters box and click Update, then the preview grid below shows exactly what I'd expect (only the Videos tagged with "foo").

My problem:

The view seems to work just fine, but I can't seem to get it to work when actually viewing the page. How do I get my Page configuration to pass along the term argument to the View so that the View can properly filter the results?

I set the path on my custom Page to be /videos/!videotype, I've set the %videotype argument so the Context is "Taxonomy term: ID" (with Argument Type = "Term name").. but I can't seem to figure out the rest of the settings.

In my view, I've named my contextual filter "Video Tag Filter" and in my Page configuration, when I edit the Settings on the above View Content Pane, it gives me a dropdown labeled "Video Term Filter" (which is different from Video Tag Filter, I'm not sure where the Video Term Filter name comes from, I've looked through all the menus I can).

It doesn't seem to work though. Can you help me out?


texts: Custom handler isn't displayed in the handler list on the development server

texts:
Webform custom handler is not showing in DEV server but it works in local.It makes very difficult to save additional information.

namespace Drupal\demo_module_dym\Plugin\WebFormHandler;

use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;

/**
 * Form submission handler.
 *
 * @WebformHandler(
 *     id = "demo_module_dym_registration_submission_handler",
 *     label = @Translation("Registration form handler"),
 *     category = @Translation("API"),
 *     description = @Translation("Set User Information on hidden field before submit form."),
 *     cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
 *     results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 * )
 */
class RegistrationFormHandler extends WebformHandlerBase {

  public function preprocessConfirmation(array &$variables) {
    parent::preprocessConfirmation($variables); // TODO: Change the autogenerated stub
  }

  public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {

    if (\Drupal::currentUser()->isAnonymous()){

      $memberid = $form_state->getTemporaryValue('memberid');

      if (isset($memberid)){
        $webform_submission->setElementData('memberid', $memberid);
      }

    }
    parent::submitForm($form, $form_state, $webform_submission); // TODO: Change the autogenerated stub
  }

}

Is there way to debug to find the cause webform handler not showing in handler list on sever?


texts: File structure for custom modules in Drupal 7

texts:
I want to organize non-core (modules that are not bundled with core) modules in Drupal 7. This is my proposed structure:

Contributed modules - downloaded modules that are untouched
Custom modules - downloaded modules that are modified to suit the requirement
local modules - self-developed modules

I GUESS, the best approach for this is to make three folders within sites/all/modules like below:

sites/all/modules/contrib
sites/all/modules/custom
sites/all/modules/local

Now, there are two ways to install a module:

Manually
From the admin panel

While installing the new module manually, everything is fine. I can just go to the directory and place the module there.

But how to install a newly downloaded module in sites/all/modules/contrib from admin-panel?
Moreover, is there any better approach for organizing non-core modules?


texts: Error uploading file. An unrecoverable error occurred

texts:
I've been troubleshooting a form in Drupal 7 that has two file upload fields.

If you upload a file with one field, then the other, the second upload will usually give an error. This occurs regardless of the order that the files are uploaded. The error does not occur if the files are both added to the "Choose File" fields and the whole page is submitted at once with the save button. The error also does not occur if JavaScript is disabled in the browser, and the individual upload buttons are used.

The easiest workaround I can imagine would be to disable javascript for the form controls on the specific /node/add page, but I do not know how to do this, and I have been unable to find people with a similar need.

The server is PHP/Apache2, with mod_security disabled and with the PHP post size limit and uploaded file size limit set to high limits as per the screenshot. File uploads work normally, leading me to rule out permissions as a culprit.

The watchdog logs and server error_log have no messages of interest, unfortunately.

If anyone has any advice to disable javascript for a page, or to resolve this error, please let me know. Thanks!


texts: Node edit page not showing up using page.tpl.php?

texts:
I'm working on a new drupal 7 site right now (I'm new to drupal) and currently have given the ability to users to create nodes. The node creation page (url.com/node/add/) works just fine and uses the page.tpl.php template.

However, when I'm using the edit page (url.com/node/NODEID/edit/), it doesn't even load a page.tpl.php file. I went ahead and added some code to my page.tpl.php file to see if it would even read out--which it didn't. I've found that the edit page is inserting itself at the html.tpl.php level of the site. Is there a quick way I can get this to use page.tpl.php or by creating a node--edit.tpl.php or something? Hopefully I have made enough sense, but am stuck.


texts: How to programmaticaly serve a 404 in template.php

texts:
I have the previous logic to feed a View in MY_TEMPLATE_preprocess_page.
When the URL, where I have some paremeters passed in a user friendly way, does not exist (the parameters are not correct), I am serving a "Product not found message". However, I think it is more correct, for SEO purposes, to serve a 404-Not Found page, with the correct HTTP Headers. I am trying to achive this with drupal_not_found but the page takes a minute to load and finally shows a blank screen.

Where should I put the logic and the drupal_not_found call? Must I move it to my custom module, in MY_MODULE_init() or something? I need to access $node->nid.

Example:

Correct : http://www.example.com/products/shoes

Wrong (404) : http://www.example.com/products/dsfsdfswerweipwr


texts:
I am using a date field in a content type.
I want to make it work similar to the date/time input in facebook events.
When I use date field as a Pop-up calendar it appears like this:

For date input it is fine as it is – but for the time imput I would prefer to have a drop down field (select list) with the date input as pop-up calender here. When I try this...

$dropdown_time_array = array('12:00 pm','12:15 pm','12:30 pm','12:45 pm', );
if($form_id == $form_id_node){
$form['field_date'] = array(
     '#type' => 'select',
     '#default_value' => '1',
     '#options' => $dropdown_time_array,
  );
}

…it actually overrides the whole field – including the date input.

Any suggestions how I can do this?


texts: How do I stop automatic double break tags in ckeditor?

texts:
After updating the ckeditor module i find that saving existing content results in adding another break tag following existing break tags. When i create new content and press enter and save the final result has an additional break tags.

This is what i should be seeing according to the source button on the editor:

The quick brown fox jumps over the lazy dog. The five boxing wizards jump quickly.

Pack my box with five dozen liquor jugs. Jackdaws love my big sphinx of quartz.

This is a second paragraphs made with two line breaks. Lets see if the editor decides to use two break tags or 4 break tags. These should also be enclosed with a paragraph tag instead of separated by two break tags.

This third paragraph is now being separated by three break tags. Lets see if the editor decides to make this as size break tags instead of just three break tags. This Should be wrapped around a paragraph but also have a break tag above it.

However what i see when i save the page ends up being:

The quick brown fox jumps over the lazy dog. The five boxing wizards jump quickly.

Pack my box with five dozen liquor jugs. Jackdaws love my big sphinx of quartz.

This is a second paragraphs made with two line breaks. Lets see if the editor decides to use two break tags or 4 break tags. These should also be enclosed with a paragraph tag instead of separated by two break tags.

This third paragraph is now being separated by three break tags. Lets see if the editor decides to make this as size break tags instead of just three break tags. This Should be wrapped around a paragraph but also have a break tag above it.


texts: Product Page Uploads and Automatic Updates

texts:
Right now my website has ubercart. I was wondering if there was a way to make it so when a user uploads a file with a description/price/etc that the product page would automatically update with their new upload.

I'm making a user based artist website. Where the users can upload their own art works and sell either a digital copy of their work or a physical copy (their choice ultimately), and I was wanting some help with the logistics of doing such a thing.

The website is currently running with Ubercart and all of its required addons AND the CorporateClean theme.

Any help would be very appreciated.


texts: How to use domain access module for localhost

texts:
I want to use domain access module for my xampp localhost.
Any one knows how to configure it for localhost.


texts: Views contextual filter when page is set as Home / front?

texts:
I have a views block pulling in a paragraph. It's set to pull content based on contextual filter "Content: ID" set to a default value of "content id from URL"
This all works fine for the pages where I've placed the block.
But, one of those pages has been set to be the home page. I understand why the view's results don't show on the home page - in that scenario, it's no longer the correct ID.
So how do I tweak it to show those views results, for the home page (on a site with multiple translations)


texts: Why are variables & CSS loaded in the overlay?

texts:
This seems really weird to me and makes no sense.

I'm using a custom theme, with Seven as the administration theme (inside the overlay).
Why on earth are variables such as $base_url loaded in the overlay (and produce errors) when I only called them in my page--front.tpl.php (in my custom theme)? The same goes for the CSS; it is messing up the admin theme.

I even renamed my style.css and used drupal_add_css() to call it, but the result is the same.
I don't get why the administrative theme is looking at my custom theme files.

Surely I don't need to add arguments to all the variables, and make my CSS calls more specific, or do I?


texts: How do I find the max length of a field (e.g. title field)

texts:
I would like to retrieve the maximum length of a field programmatically, for instance the $node->title field .

I am writing a module that sets title and I don't really want to hard-code '255'. I am using Drupal 7.


texts: Why is my Views row template not loaded?

texts:
I am using Views 3.

I have created my view and get these theme suggestions:

As you can see I created a --presse-page.tpl.php file bold marked in the second block. It works fine, but I need to style only the rows. So I created a views-view-fields--presse.tpl.php file, but if I rescan the theme, it does not appear.

Why not?


texts: How to update value of single field of same node using node_save?

texts:
The problem statement:
I have one content type called 'Employee' which has 10 nodes.  I have to perform the voting for each node. I am saving the vote count in the field called 'vote count'.
But when I met the below scenario I have an issue of updating vote count for a single employee.
Scenario:
20 people voting for one employee at a time. This means the node will save the 20 times for updating the vote count. This may lead to race_condition while saving the node. But vote count is not updating correctly. This m=is due to race_condition?
I am using the lock_aquire() and lock_release() in below code.
is it right way to use this two functions while saving same node multiple times?
or
any other way to update the count?
I have tried below attempt so far:

added ajax call back in js

jQuery.ajax({
        type: 'POST',
        url: '/ajax/vote',
        dataType: 'json',
        data: {"nid": nid},
         success: function(response){}
});

menu hook with path :

/ajax/vote

A page call back function general_voting_update_vote to save the node;

function general_voting_update_vote() {
          $lock_name = 'register_vote';
          $nodeId = !empty($_POST['nid']) ? $_POST['nid'] : '';
          $node = node_load($nodeId);
          $vote = $node->field_vote_count_submitted[$node->language][0]['value'] + 1;
          $node->field_vote_count_submitted[$node->language][0]['value'] = $vote;
          $lock_acquired = lock_acquire($lock_name, 5.0);
          if (!empty($lock_acquired)) {
            node_save($node);
          }
          lock_release($lock_name);
}


texts: How to force to upload a image with exact sizes?

texts:
When adding an image field to a content type I can set the minimum sizes under which the image will not upload. I also can set maximum sizes but if the image is bigger the system will resize the image. How can I change this?

I need to set both limits: minimum a maximun sizes. This mean a exact size for the image, then if the image has not the exact size it shouldn't be allow to upload.


texts:
I am using redirect module with Drupal 8 latest version. It is working fine when we open any node in url, it converts node to the path alias. But issue is with a href links. When we hover on any "a" link it is showing the node number not the path alias set for that node. After click on it is displaying again path alias in the url bar.

How we can display the alias on hovering any "a" href link ?


texts: Resizing the Height of 2 blocks to always be the same depending on block with most content

texts:
I have two blocks based off views on the home page of my site:

block-views-featured-resource-block
block-views-featured-resource2-block

I want them to be the same height as each other on the home page ALWAYS. They are both drawing from nodes. The nodes for each has a description field. And it varies depending on which node is set for the home page, so the length of the description for each changes regularly.

I want each block to expand in size to fit whatever contents are in the description field (might be one sentence or multiple paragraphs) for the node, and I want them both to resize based on whichever of the two has the most characters of content to the same size (one might end up having a bunch of white space below it, but that's ok.

Right now I have them set like so:

block-views-featured-resource-block,
block-views-featured-resource2-block {
    min-height: 350px;
    position: relative;
}

But of course this only resizes each to fill whatever contents are in each block separately...so if the content takes up more than 350px of space one might be larger than the other. I also tried adding clear: both to the above and overflow: auto but neither of those seemed to help.

Anyone know of a way to do what I want with css?


texts:
I want to print a link in place of a field in case of No Results Behaviour.

The link is to admin/commerce/products/add/, but drupal always add /content/ before my relative address.

I've try different attempts, but so far the only solution I've found is to write the absolute path.


texts:
I'm trying to rewrite the output of a link field in a view in Drupal 8, to include a font-awesome icon, I have tried overriding my view field template in twig, but all i'm getting in the twig template is {{ output }}, which contains a rendered link already.

Desired output

Current output

http://www.facebook.com/profile


texts:
I have master content type

content type Room,
content type Projects,
content type vaccine.

This is how these related

a. Room ID[node] of room content type is entity reference field[field_roomidd] in Projects content type, also in vaccine[field_vroomid].

b. and vaccine id [node of vaccine content type] is entity reference field in content type projects.

Now I want to create view of content type Room and projects and  have merged the two views of content type Room and Content type projects.

My requirement is whenever we select room id in filter condition it should show the for that particular room id what's the vaccine created, and projects are exist....I am stuck here please anyone help me on this.


texts: Programatically accessing block settings

texts: Is it possible in Drupal 7 to load block visibility settings programatically in module? I'm rendering block programatically and I want to include checking those settings, so it still will be possible to hide block from UI. Property of "status" and "visibility" are not enough, since it's possible that the block won't be placed in any region at all.


texts: True/False exposed Views checkbox for Computed Field

texts:
Imagine a user has ten fields of type "List(text)" which each have for their widget "Check boxes/radio buttons". Each one is displayed to the user as a single value checkbox which asks the user to state whether they agree with something or not.

A distinct Computed Field of data type TinyInt uses custom PHP to examine the values of these List(text) fields checkboxes. If all are checked the Computed Field is set to have the value of 1. If any or all are unchecked the Computed Field is set to have the value of 0.

(Ideally I would like the Computed Field to be of Boolean type - so simple TRUE/FALSE - but this does not seem possible out of the box. Anyway, the real question is the following.)

In a View with exposed fields, how can you use the Computed Field as an exposed field that offers the user a single checkbox: "Find all users where the Computed Field value is 1: [•]".

If this isn't directly possible, I'm happy to have a workaround that involves creating a distinct (hidden) field in the user profile and then uses this for the Views exposed filter search. But I can't think of a way to do this right now... Thanks.


texts: Embed a single webforms different fields in to two different pages - Drupal 6

texts:
In Drupal 6 , I have a webform which asks for basic info like the Name and email. Then on the basis of if the user is a special user (asked with option button) will choose to ask more questions if they are one else will not ask anything else.

I have created 2 webforms to do that. Is there a way to do that with only 1 webform?
More so is it possible to embed the remaining fields in to a different page.

Thanks.


texts: How can I change the default system message shown on form submission

texts:
I've created a business card request form as an EntityForm and am scratching my head trying to figure out where in the module i can find the line - ( " The submission has been saved " ) .

This message displays after every form submission/edit/save, and I would like to get rid of it but cant figure out where its coming from !   :)


texts: How I do I remove the User menu from the top right corner?

texts:
How would I go about removing the "User menu" from being displayed in the top right corner of the site when logged in? It is set to display "None" in the block, yet it seems to be up there by default.

Other than using CSS to hide it, what is the recommended way to remove these links? I've got the login/logout links in my footer instead.


texts: Views Module "Page" and Contextual Filters

texts:
I have a /press-releases section of my site. The /press-releases url shows a summary of all articles (press-release content types) and there is a block on that page that is generated by a view which displays the latest press releases by release date.  That part works great.

When a user clicks on one of the listed articles, I need it to go to the full article, but use a special "View" for press releases (articles).  I think I need to use some combination with the page view's "Path" field along with the Contextual Filters, but I can't figure out the correct combination.

In other words, how do I show my Press Release (article) Page View when the url is /press-releases/anyarticle ?


texts: Bypass Redirect Rule which acts on user login, while logging through one time login link

texts:
I have a redirect rule in place which takes user to home page after login, I need to bypass this rule when a user logs in with one time url login link which is sent in account creation email.

I am assuming there should be condition I need to put in the redirect on user login rule,but I am not finding it.I tried by putting a condition that if the site current page url is account one time login url then rule should not trigger,but its not working as the condition does not satisfy.


texts: Add an existing node as a translation to another node

texts:
I am migrating contents from a multilingual website. I'm using Feed modules to import all the nodes so, in the end, I have multiple nodes that are in English and multiple nodes that are in French. Then, i wrote a DRUSH command where I have a CSV file that contains URL Alias of both slug of English and French. I can then process that info and get the node ID of both related Node.

But I just can't see how I can't tell drupal to attach an existing node (FR) as a translation of another node (EN). Does anyone has ever wanted to do something similar?

Thanks!


texts: Views: how to enable Title Link per role?

texts: In Drupal 7 Views, there is an option to Link title field to the original piece of content. How can I enable the link per role? I only want to show the link for administrator and staff, so it will be much easier to modify.


texts: Create a Rules link to update a field in a submitted webform

texts:
I have a view which is a list of submitted webforms. I want to add a link using Rules link that, when clicked, updates a field in the submitted webform (specifically, updates a hidden field with the current date).

Is this possible?


texts: Form API: Populate tableselect options with AJAX

texts:
I want to add a series of sections to the node create/edit form I have for a custom content type. They all work in a similar fashion, in that I pull data from another database and display it for the user to further modify. I will either use a tableselect with checkboxes, or a tableselect with a taxonomy select field (which I will have to research how to do).

The user should have the option to reimport the data if it has been changed on the database by hitting a button that has an AJAX callback attached to it. That's where my problem comes in. I am having a problem with getting the tableselect options to repopulate after import. It seems like the data is being pulled correctly. But the tableselect doesn't repopulate after import, so I assume there is either something wrong with how I have written my submit buttons or the AJAX callback. I can't figure out what exactly is wrong though. How does one handle something like this, especially when one needs multiple AJAX submits?

In the pastebin below I have my entire form, which right now has 2 tableselects and corresponding AJAX callbacks. I need to have 4 in the end. And I have only included the callback function for one of them since they are exactly the same, except for what they query in the DB.

Pastebin, because the code is too damn long: http://pastebin.com/csetteZp


texts: Rules "Add item to list" does not work with users

texts:
I'm trying to add a user to a field with Rules. The rule has the following workflow:

On Node Being Flagged
Node is of Type
Add Item To List

Item is the flagging user, and the list is a user reference field. This works with taxonomy terms, but not with usernames.

Do you have any idea?


texts: How to correctly format a POST request to the file_upload Rest Response?

texts:
This is my first time posting a StackExchange question, so thanks in advance for your patience.

We are attempting to upload an image to a headless Drupal application using the File Upload REST resource. In testing the endpoint with Postman, we've run into a weird issue. We are able to target the endpoint and upload an image fine through Postman's 'binary' body type, in which you just attach an image to the GUI and it does the rest for you. But if we use the 'raw' body type and pass in the Base64 code for the image, the image entity is created but the actual appears broken in Drupal. According to the linked documentation, it appears the binary data just needs to be passed in directly with the appropriate headers.

So my questions are: Is there a specific way to format or package Base64 image information to upload directly to Drupal? Am I falsely equating Base64 and binary data? Does anyone have any similar experience? Thanks a ton for taking a second to read this.

For context:

Our endpoint in both cases is http://localhost:8000/file/upload/{entity_type_id}/{bundle}/{field_name}?_format=json

And our headers are:

Content-Disposition: file;filename="test.jpg"
Content-Type: application/octet-stream

And when we attempt to preview the image in Drupal after passing the Base64 directly, this is what the preview looks like (an ominous white outlined square on a black background):


texts: cache_token table doesn't exist after Drupal 6 to Drupal 7 upgrade

texts:
I recently created a D6 site to import some content using the D6-only import_html module, then upgraded it to D7 (in a slightly roundabout way I can describe, but shouldn't be relevant to the question). Since doing so, whenever I enable new modules and am sent to /admin/modules/list/confirm I see Drupal error messages like the following:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal7_gimported.cache_token' doesn't exist: TRUNCATE {cache_token} ; Array ( ) in cache_clear_all() (line 169 of /Users/tomash/Sites/drupal7/includes/cache.inc).

The modules do seem to install correctly, but the error is annoying and alarming. I would just copy a cache_imported table from a clean Drupal 7 install, but I wanted to check whether this is the right approach in general, and whether the error points to deeper problems.
Relevant information, which I can add to

I had the Token module installed in the Drupal 6 installation
I've enabled the Drupal 7 version in the upgraded Drupal 7 installation
I'm running this all on my localhost, which has rarely yielded errors before


texts: Where to start looking up if there's something wrong with cck field variables?

texts:
in short: Something in my zen-based custom theme is keeping a couple of cck fields from being display on my page. Basically my question is where to get access to the variables that are supposed to contain the html for the cck fields (which are missing when I was looking them in firebug).
Below I explain why I think it's looking up the variables that might bring me closer to a solution

So I made this custom node type (events) with cck fields added. Also made some content using those fields. Added some css and it all displayed fine.
Later the taxonomy terms below the title and some metadata bugged me so I followed along with a 'theming cookbook' pdf book that taught me how to make a node-events.tpl.php and simply deleted php variables like $terms. This worked great.

Obviously this also means that all this time, the view permissions of those fields have been checked and also that the display options under 'display fields' have been set to standard all the time.
I also ruled out that the issue could be anything else than theme related as my cck fields do show up in a stock Drupal theme. The theme for my site is a zen-based custom theme.

So then even later, after I made a view for this node type and started adding css to that view I noticed at some point that my image field and two other fields are missing. It's hard to tell if they disappeared because of things that I did when creating the view and adding css (which would surprise me)


texts: Exportable and Fieldable Blocks in Drupal 7

texts:
I have a project where I have two competing requirements for blocks.

First, I'd like to have blocks be fieldable. There are blocks on the site that contain static content but should have the block title as a link, and have an icon associated with the block.

Secondly, although these blocks are not "configuration" per-se, the client would certainly say that their site was broken if they didn't exist. Because of this, I'd like to be able to export the blocks using Features so that they can be included in version control.

I've looked into both the Bean and Boxes modules. Bean supports making the blocks fieldable by defining new block types. Unfortunately, while the block type is exportable with Bean, the block itself isn't.

I've also looked into Boxes. Boxes supports exporting blocks, but isn't fieldable by itself. If I add the Entity Box module to Box, I get fieldable boxes, but those new boxes aren't exportable.

Help! Is it even possible to do what I'm trying to do here? Is there some way other than creating Features exportables to easily synchronize small pieces of content so that all of the developers are working on a consistent version of the site?


texts: Which core module provides the default send email action for use in rules?

texts:
There is a core module (might be related to core actions) that allows your to send an email via VBO. What is the name or where is that function located in core?

For e.g. When I am modifying the system mail settings, what "module" in core provides this functionality? (See screenshot)


texts: problem with Views module (installation)

texts:
I had a views page created on my site and it seemed to work well. Then I started to update some of the modules that updates wre available for and then all of a sudden, my views module didn't seem to be installed anymore. So what I did, went back to reinstall it, now the link to my views page on the site is back (http://www.quaaoutlodge.com/special-events) but when I click on it, I get this error: Fatal error: require_once() [function.require]: Failed opening required '/home/content/q/u/a/quaa7882/html/sites/all/modules/commerce_kickstart/modules/contrib/views/includes/view.inc' (include_path='.:/usr/local/php5/lib/php') in /home/content/q/u/a/quaa7882/html/includes/bootstrap.inc on line 3047
commerce_kickstart is a module I have removed in the meantime and am no using it anymore nor is it in my modules directory. Why is something still referring to it? How can I fix this?

Thank you,
Ron


texts: How to prevent the addition of HTML in "Full HTML" text format?

texts:
Sometimes, Drupal has the annoying habit to automatically add HTML to the content's source, generally <br/> and <p>, even when the text format is set to "Full HTML".

This is really annoying and I can't find any way to prevent that.  Any idea ?


texts: Can I add my own if statement to node.tpl to test if field groups are null?

texts:
I have a content type with 4 different field-groups utilizing the Field Group module. I want to test to see if those groups are empty and render them and some additional HTML if they are NOT empty, and not render them, and additional HTML, if all the fields in the group are empty.

I'm not sure of the syntax to test if field groups contents are NULL, any pointers there?

So far this still isn't working for me. I have a field group that I know is empty group_factory_images

When trying to use the code from the answer:

<?php if(!isset($node->group_factory_images))
print 'Yep, Empty';
?>

It just prints the "Yep, Empty" string.


texts:
In Drupal 7 it is possible to set a default parent item at admin/structure/types/manage/article/edit.

Where is this option in Drupal 6?

If it isn't possible to do this in Drupal 6, is there a contributed module that will achieve this?


texts: How to create a 'new entity' form as block in or under an entity (using Eck entities)

texts:
There is this module 'Form block' that creates blocks of node add/edit forms.
However, that module is not compatible with ECK entities (or custom entities in general)

What would be a good approach to create a similar solution for ECK entities?


texts: Is it a good idea to split a Drupal site into multi-site one for editors/admins and another for front end users?

texts:
To illustrate:
I have a multisites with a shared db edit.example.com and site.example.com. They share many tables but do not share all (a work in progress to determine what exactly need to be share). For example, the system table is not shared in order to be able to control what modules need to be enabled across all, on edit.example.com only and on site.example.com only. Does this can help performance?
Is this a good idea or is it just adding an extra level of unnecessary complexity?For example I see caching becoming a problem because cache_page is not shared, or even if it is shared.

If there are any references out there please refer me to it.


texts: Rule to add product after a certain product is added

texts:
We have certain products in our range that have a second product added automatically when ordered.

I have tried to setup a rule through workflows, but cannot get it to work.

I thought this would be a common question, but i cannot find any documentation on it either.

Does anyone know the rules setup for this?

Any help is much appreciated.

This is what ive tried:

{
"rules_add_second_product" : {
"LABEL" : "Add Second Product",
"PLUGIN" : "reaction rule",
"WEIGHT" : "3",
"TAGS" : [ "Secondary" ],
"REQUIRES" : [ "commerce", "commerce_cart" ],
"ON" : [ "commerce_cart_product_add" ],
"IF" : [
  { "entity_exists" : {
      "type" : "commerce_product",
      "property" : "sku",
      "value" : "123456"
    }
  }
],
"DO" : [
  { "commerce_cart_product_add_by_sku" : {
      "USING" : {
        "user" : [ "site:current-user" ],
        "sku" : "654321",
        "quantity" : "1",
        "combine" : 1
      },
      "PROVIDE" : { "product_add_line_item" : { "product_add_line_item" : "Added product line item" } }
    }
  }
]
 }
}


texts: I have a big problem with a database. I have a list of suscribers in an excel list with their names, phone and other info. I need to import that suscribers to my drupal website and use them for send them massive emails. How to do that? which newsletter module is better for use with my usecase?


texts:
I wanted to add the "status" field to an entity that already exists but is not mine, i.e. I cannot edit the php class where this entity is defined.
With the following code I add the field in database, but I don't have access to the "isPublished()" or "setPublished()" methods, because for that the entity should implement the "EntityPublishedTrait" trait.
/**
 * Implements hook_install().
 */
function project_groups_access_install($is_syncing) {
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $entity_type               = $definition_update_manager->getEntityType('my_entity');

  // Bail out early if a field named 'status' is already installed.
  if ($definition_update_manager->getFieldStorageDefinition('status', 'my_entity')) {
    return t('The publishing status field has not been added to my_entity.');
  }

  // Add the 'published' entity key to the my_entity entity type.
  $entity_keys              = $entity_type->getKeys();
  $entity_keys['published'] = 'status';
  $entity_type->set('entity_keys', $entity_keys);
  $definition_update_manager->updateEntityType($entity_type);

  // Add the status field.
  $status = BaseFieldDefinition::create('boolean')
    ->setLabel(t('Published'))
    ->setDescription(t('A boolean indicating the published state.'))
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE)
    ->setDefaultValue(TRUE)
    ->setDisplayOptions('form', [
      'type'     => 'boolean_checkbox',
      'settings' => [
        'display_label' => TRUE,
        'default_value' => TRUE,
      ],
      'weight'   => 120,
    ])
    ->setDisplayConfigurable('form', TRUE);

  $status->setInitialValue(TRUE);
  $definition_update_manager->installFieldStorageDefinition('status', 'group', 'group', $status);

  return t('The published field has been added to groups.');
}

My question is: how can I make that entity implement the EntityPublishedTrait class to have access to those methods?


texts: How do I remove the "Request New Password" link?

texts:
When I visit www.example.com/user, there is a page that shows the login/password and as well as a "Request New Password" tab.

How do I remove this "Request New Password" tab from the user page?


texts: Show taxonomy children terms when searching parent term

texts:
I have a question about taxonomy term search and I hope someone can help.
What I need to do is be able to perform parent taxonomy term search and pull all children terms so that the resulting page shows content tagged with children terms to the searched parent term.
There might be already a solution out there but I can’t seem to find it, so if someone knows where to get to it, please let me know.
I have already created a vocabulary, which contains about 100 terms; some terms have with sub-terms (children terms).
When I search for a parent term, I don’t get the content tagged with its children terms related to the parent. When I click the parent term the only thing I get is: “There is currently no content classified with this term”.
Thanks for help.


texts:
I have a requirement where my website serves both products and services. I am using Drupal e-Commerce module for the same. It works perfectly fine for Products where we can set price for each product and user checks out from cart.

However, Services differ in their workflow. Each service product for ex: Electrician, will be associated with a service resource person, let's say Mr. XYZ. Now following are the requirements:

Service Person is allocated to a service request product.
The price of the service will be estimated after the service is provided.
Rating & Reviews provided in case of service should be attributed to the Service resource as against that of the Product where rating is associated with a product.
The price for a provided service has to be updated to the Order after the service is completed.

These differences are identified for starters, many more complex things might come in future. I have searched enough and I could not find a module which would satisfy the needs of both products and services. In fact, there is none for services. Is there a way to achieve what I want?


texts: JavaScript errors with 'Add collection', 'Select media' (Media, Field Collection)

texts:
I drupal 7 site that I did not build but now maintain has developed an odd error.  About a month ago the site lost the ability to add an image to a Media field inside a new addition of field collection.  Looking into it, this is what I find:

The first few warnings are nothing that I can see would harm things.  The media.popup.js error is nonsense:

dialogOptions.buttons[ok] = function () {
  alert('hell yeah');
  return "poo";

  var formattedMedia = this.contentWindow.Drupal.media.formatForm.getFormattedMedia();
  if (!formattedMedia) {

I have yet to see that code be reached, though it looks a little unprofessional to have such things in a contrib module.

When I scroll down the node edit form I see see the next segment.  The Bulletin error has to do with Google Syndication code linked in, and can be ignored for now.

The piece of the screenshot after that is when I try to trigger the field collection's "Add Additional Item" button from the console.  Nothing happens.  I am not sure if I did it right, but I included it in this screenshot in case it helps identify anything.

The final segment shows the messages that appear when I click the Add Additional Item button.  A new field collection instance is actually added to the form, and if the console was not open I would not know that something was wrong yet.  I get from 2 to 5 instances of that "object is undefined" error any time I do this.  The "too much recursion" error occurs about 1 in 15 tries, so I do not know if it is relevant.  I have all cache and compression turned off, and this is a local virtual box copy of the live site so I do not have to worry about killing it in the investigation.

The problem is these "object is undefined" errors block the use of the Media module's Select Media button for a field on the node.  First time this problem was noticed was when a new slide show entry was being added to an Article node.  The Add collection button causes the error, and the Media button then does not respond but throws some "this.hoverable" error.  I went over to another content type that has a field collection that contains only text, but also has a Media field on the node itself.  The field collection generates the same error, I switch vertical tabs to get to the Media field and it behaves the same as the media field inside the collection.  JQuery Update is used to keep the admin screens on jquery v1.5 because it is needed for the Media module.

Modules involved:

Drupal 7.38
Field collection (field_collection)  Module  Enabled      7.x-1.0-beta8
Chaos tools (ctools)  Module  Enabled     7.x-1.7
jQuery Update (jquery_update)   Module  Enabled     7.x-2.4
Media (media)      Module  Enabled    7.x-1.5


texts:
I'm trying to put my entire website under https connexion, but my css and js are not loaded. I don't know why.

I had this code to the htaccess at the root of the website :

  # Force HTTPS and WWW
  RewriteCond %{HTTP:HTTPS} !on
  RewriteRule (.*) https://%{SERVER_NAME}/$1 [QSA,L,R=301]

And didn't touch anything else. If it's relevant, I'm using a hosting from online.net (french provider).


texts: Log out URL returns 503, redirects to path with double slash

texts:
When users access /user/logout they receive a "Page Not Found" error, and the URL they are forwarded to looks like this:

https://wwws.site.com/dir/site_name//dir/site_name/

Why is this redirect happening and how do I change the logout path so that it wouldn't create the double slash?


texts: Losing superfish menu item after logging out from administration panel

texts:
I have a superfish menu as my nav menu bar. I customised it and added some pages for each menu item.

When I log out of the administration panel, as a general user I can only see the first menu item, all other menu items are gone.

[edit below]

Right, found out that the problem was because my other three menu items are all link to '.../add/node'. Superfish will not show empty links on the menu bar. However, I actually don't want some of the items link to anywhere as they all have submenu items. I want the link to remain empty so that the user can click on the submenu item. How can I achieve this?


texts: How to dynamically redirect user from /foo/X to /bar/X?

texts:
So far I did the following:

I've installed Redirect and Token modules.
I've applied the patch for Redirect module to support wildcards.
I've applied the patch for Redirect module to implement hook_redirect_response_alter.
I've defined the following hook_redirect_response_alter to support and parse the tokens.

use Drupal\redirect\Entity\Redirect;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Component\Utility\UrlHelper;

/**
 * Implements hook_redirect_response_alter().
 */
function MYMODULE_redirect_response_alter(RedirectResponse $response, Redirect $redirect) {
  $uri = $redirect->getRedirect()['uri']; // "internal:/bar/[current-page:url:args:last]"
  if (!empty($uri) && strpos($uri, '[') !== FALSE) {
    $uri = \Drupal::token()->replace($uri); // "internal:/bar/"
    $external = UrlHelper::isValid($uri, TRUE); // bool
    $redirect->setRedirect($external ? $uri : explode('/', $uri, 2)[1]);
    $response->setTargetUrl($redirect->getRedirectUrl()->setAbsolute()->toString()); // "http://localhost/bar/"
  }
}

I've added the following redirect at /admin/config/search/redirect:

From: foo/*
To: /bar/[current-page:url:args:last]

Based on the above, I'm expecting that typing foo/X will redirect to bar/X, and foo/Y to bar/Y accordingly, and so on. However, the above token is replaced with an empty string. Similar thing when using token such as [current-page:url:args:value:2], it's not replaced at all. I've also learned here that using [redirect:url:args:last] won't work either, as the token is generated based on the entity type, so Redirect module isn't aware of it.

I've tried a few more tokens found at /admin/help/token which can potentially extract the second argument from the path, but I haven't found any suitable or working as expected for this task.

For example:

More details

Applying $redirect context for token's replace() method, as suggested in the comments, didn't work as expected.

So the following line:

$uri = \Drupal::token()->replace($uri, ['redirect' => $redirect]);

populates some token with redirect prefix, however it wrongly replaces the current path, e.g. [redirect:url:args:join:/] becomes admin/config/search/redirect/edit/25 for every page.

I've also tried to populate context for the current-page tokens, but it was requiring the current path exists, however during redirect the current path doesn't exist in the menu routing table, so it can't be loaded (I've tried Url::createFromRequest() and \Drupal::request()).

Question

What I'm missing? Is there any easier way to achieve the same thing?


texts: Module for recommendations based on Solr

texts:
I would like to ask if there is any module for recommendations (products,nodes etc)
based on Solr.

I have searched on Drupal.org, and I have found Content recommendation modules, which doesn't list any module using Solr.


texts: How to create a catalog site with views and taxonomy?

texts:
I'm trying to setup a site where users can download pdfs that are sorted into different categories based what type are. I've coded out what I want in a html version (which is currently live here) but I need to make this into a CMS (first time for me in Drupal, I've been using other CMSs such Wordpress).

Here's the structure I'm after (also would like to have the URL aliases mention below):

Displayed on Main Download Page (url: domainname/downloadpage):

(Probably a block)

First Top Category

First Sub Category
Second Sub Category
Third Sub Category

(Also a block)

Second Top Category

First Sub Category
Second Sub Category
Third Sub Category

Displayed on Top Category Page (url: domainname/downloadpage/firsttopcategory):

(A block but doesn't have to be)

First Top Category

First Sub Category
Second Sub Category
Third Sub Category

Displayed on Sub Category Page [already worked this out- just trying to link/incorporate it] (url: domainname/downloadpage/firsttopcategory/firstsubcategory):

First Sub Category
[in a table]

Download Name  Field1 Field2  Download Link

Name  Field1 Field2  Download Link

I've already worked out how to create a content type for this, all I need to get this structure into place. This has been a good help but I can't seem to get the way I need it with what I'm after. If you could point me in the right direction in order to archive this, it would be very much appreciated.


texts:
Is there any function equivalent to the (D7) search_data() in Drupal 8? I would like to get the search results as a renderable array or html for a given keyword programatically.

In D8, the SearchController.php provides the view which does the same, but I'm not sure how to call that from my module?

It uses

$plugin = $entity->getPlugin();
$plugin->setSearch();
$plugin->buildResults();

to get the result.

How do I create the SearchPageInterface entity which contain the getPlugin() method? Or is there a way to create an instance of the default search plugin directly?

My requirement is to show the search results in a custom page where the search results are wrapped by the custom page content. I've implemented this in D7 using search_data function. How can I achieve similar result in D8?


texts: The famous counter module "counter" is marked unsupported

texts: The famous counter module "Counter" is marked unsupported.  Is there another good choice for counter?


texts: Redirecting from example.com to example.com/drupal

texts:
I have Drupal 7 installed in a ./drupal directory in my web server (shared host).

I would like www.mysite.net to be redirect to www.mysite.net/drupal in a transparent way for visitors. They should see in their navigation bar www.mysite.net instead of www.mysite.net/drupal.

I also want clean URLs to work. To make clean URLs work, I have edited my drupal/.htaccess file and uncomment this line:

RewriteBase /drupal

I read a lot of posts about having Drupal in a subdirectory, but the suggested solutions don't work (they cause an internal server error, or problems with CSS and images). Most of these tutorials are based in 2 htaccess file, one in the root directory and one in the directory where Drupal is installed. They also required to change $base_url in settings.php.


texts:
in drupal commerce every time logged in as a authenticated user and can get all the way through checkout until I am redirected back to the site.
redirected to this page:
/checkout/15/payment/return/GSudAHSfaC6km6N5qbLb8jNB8Wu3x3DZ0TzvWT0O4io?payment_method=paypal&token=EC-5Y966101448403611&PayerID=HF6BGTV3LGDT4
I get sometimes an Access Denied error and logout ! and The order is not processed. And sometimes is ok and processed complete !
I can't see that I am missing any permissions that would prevent anything. I also can't see where I would specify the page to return the user to at this point in the process. Any thoughts?
This problem only on chrome ! firefox is ok !!


texts: I want change format display View Data Export from table to unformatted list


texts: How to give access to the files of node for individual users?

texts:
In my website I have these modules enabled: File Entity (fieldable files), Media, Rules, Entity reference.

The default download method is: Private local files served by Drupal.

So when userA upload file to node. userB can't see it.

Q: How to give access to view file by entityreference(user) for userB?

UPD:

I create subdomain http://filesaccess.onenglar.com/

So you can login:

user: root

pass: root

UPD2:

Sharing access i think by entity reference field (user)

But how share access to the files of node for individual users?))


texts: When using the Entity API, is it fairly simple to interact with Taxonomy, Path/Pathauto, XML Sitemap, and Views? If so, what parts of the API should I be looking at?


texts: Is it possible to set a region on a specific page? I've created a page and I only want it to display it there and not elsewhere.


texts: How to display the trimmed value and the full value of a field in a same node

texts:
I have a content type with a text field that i want to render trimmed and full in the same node.

I've set my field to "trimmed" and rendered it in my node.tpl.php using
<?php print render($content['field_image_desc']); ?>

Now i need to render the same field but not trimmed (to display it in an overlay div).

Thanks for helping...


texts: Are node data stored in the render array $page?

texts:
Are node data (e.g. title, body, comments) stored somewhere in the renderable array $page, and converted into HTML during rendering? Or does a renderable array just contain properties that indirectly cause to load particular templates files?

Where are variables that store these values printed?


texts: How to pass an array from module to template file?

texts:
I have an array printing in module file. I want to theme that array data,so I am not getting how can I get that array data in template file. I don't want to create theme function and all. is there any inline solution to pass from module to template. My code is like below.

$data['listfiles'] = array(
    '#theme' => 'table',
    '#header' => $filesheader,
    '#rows' => $rows,
    '#empty' => t('No content available.'),
  );

  return $data;

I want to pass $data variable to the template file, so that I can theme the data.Thanks in advance for any suggestions.


texts: Upload External File to Drupal File System

texts:
Situation

I would like to be able to upload files programmatically from an external source to the drupal file system. I was thinking of making a RESTful API that allows me to save external files into my site's public file path. The file is an excel file as well if that changes anything.
Problem

Currently, I am thinking of just using an S3 bucket to store the external files. Then within my site, I would simply run a GET REQUEST and programmatically save the file. I was just hoping there was a way to simply POST a file in drupal without me having to use Amazon's S3.
Parameters:

Drupal Version 8.8
Drupal Site BackEnd= PHP 7.3
External App FrontEnd = Vue.js
External App BackEnd = .NET Core
Required File Type: .xlxs
Secondary File Types: .csv, .docx, .json, .jpeg, .mp4, .txt

TL;DR

How can I make it so another site/app can upload files to my site? (using JavaScript)

Notice:
I understand StackOverflow is only meant for help with code issues but I would greatly appreciate some help getting started and if not at least some very useful links that are credible. Some of the research I have found is not useful seeing that I am on Drupal 8.8


texts:
I am porting my module Background Video from D7 to D8. This module is using third party Library. As this file is not available on 'packagist.org', it is not working as normal way defined in S3FS module's composer.json file here.

I also tried this method also:

    "repositories": [
{
    "type": "package",
    "package": {
        "name": "Jqeury Video Background", //give package name to anything, must be unique
            "source": {
            "url": "https://github.com/georgepaterson/jquery-videobackground", //git url
            "type": "git",
            "reference": "master" //git branch-name
        }
    }
}],
"require" : {
  "georgepaterson/jquery-videobackground": "dev-master"
}

Someone help me to solve this.


texts: change the date format to dd/mm/yyyy in views of the webform

texts:
I have created the fields for the view extracte from a webform. It is working perfectly. But when i try to extract the date field it just get the date it yyyy/mm/dd format. Now I searched alot but no where i could find easy steps to convert the date format of this field to dd/mm/yyyy.
Please explain in easy steps how to convert my field to my required date format.


texts: How to minify JS and CSS in D7 without using modules

texts:
One of the most promising D7 module http://drupal.org/project/advagg for minification and aggregation of CSS and JS isn't ready for production sites yet.

In such a situation which is the best option?

I also checked http://drupal.org/project/core_library but it sounds overkill.

What other good options we have inside or outside drupal?


texts: Adding repositories in contrib module composer.json?

texts:
Is it possible to add repositories from a module's composer.json instead of a project's composer.json? I've got the following set up:

Commerce Recurly (sandbox)  - and its composer.json
Recurly module fork (sandbox) - and its composer.json
Recurly API fork

I'm developing Commerce Recurly and am declaring a dependency on the Recurly module. However, the Recurly module uses API v2, and I am using API v3 in Commerce Recurly. Since the namespacing of the two APIs are different there are no conflicts when running them concurrently, so I created a fork of the API v2 to allow both to be added to my project. The result is that I am able to get both recurly/recurly-client and mrweiner/recurly-client-php-v2 concurrently installed to vendor.

Composer picks up all of the require dependencies correctly from both modules' composer.json files, as well as the patches from the Recurly Fork. It doesn't seem to pick up the repositories sections, though.

I'd expect to be able to just add the Commerce Recurly repo to my project's main composer.json like so and have everything install when running composer require sandbox/commerce_recurly:

    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        "commerce_recurly_sandbox": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/sandbox/mrweiner-3131465"
        },
    }

This doesn't work, though. I need to add repository entries for all three repos to my project's main composer.json to get composer require sandbox/commerce_recurly to correctly install everything, like so:

    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        "commerce_recurly_sandbox": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/sandbox/mrweiner-3131465"
        },
        "recurly_fork_sandbox": {
            "type": "vcs",
            "url": "https://git.drupalcode.org/sandbox/mrweiner-3131471"
        },
        "recurly_api_v2": {
            "type": "package",
            "package": {
                "name": "mrweiner/recurly-client-php-v2",
                "version": "2.12.13",
                "type": "vendor",
                "source": {
                    "url": "https://github.com/mrweiner/recurly-client-php.git",
                    "type": "git",
                    "reference": "c9f67565"
                }
            }
        },
    }

Is there some way to get composer to pick up the repositories defined in the modules' composer.json files? Having these extra entries isn't a huge deal for me right now, but when I move Commerce Recurly from Sandbox to a full project, it's going to be inconvenient to force people to add extra Repos to get things running.


texts: How to inject custom dependence in custom entity?

texts:
On Drupal 8, in a custom entity class, I'm trying to load a repository in the constructor to be able to use custom functions in the preSave().

class MyEntity extends ContentEntityBase implements MyModuleInterface {

private $customStuff;

public function __construct(array $values, $entity_type, &$bundle = FALSE, $translations = []) {
        $this->customStuff = \Drupal::service('mymodule.mymodule_repository');
  }

(The service is defined in .services.yml in the correct module)

But I have the error :

The website encountered an unexpected error. Please try again later.Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 133 of core/lib/Drupal/Core/Entity/EntityTypeManager.php). Drupal\Core\Entity\EntityManager->getDefinition(NULL) (Line: 410)

How to inject custom dependence in custom entity ?


texts: Possible to use OR in contextual filter?

texts: I know with standard filters in Views I can select "AND "OR" etc. for multiple fields but I don't see this option for contextual filters.


texts: Log Message - Page Not Found: includes/database/sqlite/log/login

texts:
When I check "Recent Log Messages", I keep finding a large number of "Page Not Found" errors with the message "includes/database/sqlite/log/login".
I've checked the site and the directory does not exist.

My questions:

Should this directory exist? If so, how do I create it?
How do I determine what is calling for this directory?


texts: Overwrite default (Bartik) block.html.twig from my custom block module folder

texts:
I have a custom block module. I want to override core/themes/bartik/templates/block.html.twig in my-module directory.

In my-module directory I have a folder templates/ and the twig file block--my-module.html.twig.

In modules/custom/my-module/my-module.module i have:

function my_module_theme($existing, $type, $theme, $path) {
   return array(
     'my_module' => array(
     'variables' => array('message' => NULL),
     'template' => 'block--my-module'
    ),
  );
}

If I insert in my build() function in modules/custom/my-module/src/Plugin/Block/MyModule.php e.g:

'#theme' => 'my_module',

my twig template is loaded from modules/custom/my-module/templates/block--my-module.html.twig, but as a child inside the default block.html.twig core/themes/bartik/templates/block.html.twig?

What I am doing wrong here?


texts: How can I override panels_everywhere with a tpl?

texts:
I have a site which use panels_everywhere but I want to create a tpl file which contains only the node without any pane for an iframe purpose.

I want to make a condition that if the domain alias is alias.example.com then use a specific tpl witch prints only the node itself without panes. How can I do it?

Actually I find a little solution but still have a problem.
The solution I found is this:

function Mymodule_preprocess_panels_pane(&$vars) {
  global $base_root;
  $domain = $base_root;
  if ($domain == 'iframe.xxx.org' && arg(0) == 'node') {
    $nid = arg(1);
    $node = node_view(node_load($nid));
    $vars['node_content'] = $node;

    $vars['theme_hook_suggestions'][] = 'page__iframe';
  }
}

and in the tpl I wrote:

print drupal_render($node_content);

But the node is rendered 5 times on the page for every pane.

Any solution?


texts: Targeting nodes dynamically with breadcrumbs

texts:
I'm using a 'resource' content type that can be browsed, searched, or accessed via a custom module. I'm also using the Custom breadcrumbs module.

I'm wondering if anyone knows a way to target [whichever] resource profile I user happens to have been viewing (dynamically since I won't know ahead of time which profile they're coming from)...and then target it in the breadcrumbs so that on pages accessed FROM the profiles (ie. a webform to give feedback on the profile for example)...a user can click the resource profile in the breadcrumb to go BACK to the profile they were viewing.

Anyone know a good way to do this?


texts: Add site details to be used as tokens throughout site

texts:
Is there a way to add additional fields to the config/system/site-information area such as "business location", "hours of operation", "phone number", etc. I would then like to be able to use that information throughout nodes and blocks as tokens or something like tokens.

That way if a phone number changes or business hours change you can just change it on the config page and it will change throughout the site.

Is this possible?


texts: Views Bulk Operations (VBO) Clear button gives error after paging and want to clear results

texts:
I use Views Bulk Operations (VBO) module. If I select some rows and 'page' (Ajax) to another page in the Table view. Under 'Selected 1 items in this view' I get a strange error after pressing the Clear button (see screenshot)?.

I use a clean install (Drupal 8.5.0) and Bartik theme.
Views Bulk Operations (VBO) module version: 8.x-2.2


texts:
I am planning to use different server for multiple purpose.
like

Groups.eg.com

Privatecontent.eg.com

review.eg.com

etc...
I have up to 5 different subdomains and everything runs in different server and different drupal installation.

I want to use the same user base across all these sites.

I am aware that if a single drupal installation have multiple sites we achieve this using domain module.

Is there a best solution for my use case.
Because we are going to load 10k users in the site.


texts:
I have a new installation of Drupal 7.52 on a Windows server and during the update of some modules I receive that /websites/mydrupalroot/.... is outside from /website/mydrupalroot!

I found this question:

https://stackoverflow.com/questions/28701991/drupal-module-installation-error-file-transfer-failed-reason-mysite-com-site

but the solution didn't work for me!
What could be the problem?
Could it be the directories privileges?


texts: I have a theme with some blocks. I have a problem with adding articles. Right now when I want to add a new article, it appears in each block that exists on the website. How can I put a new article into the specific block on the front page? Each block is about a different topic so it must have different articles. The default layout of the article is good so I want to keep it. I wanted to clone the article but after cloning and giving a new name the layout of the article is not the same as the original version. I will be grateful for your answer.


texts: Upgrade breaks Rest Export View in Calendar

texts:
We have a website that uses Views with a serializer rest export to display events on a monthly calendar. When we upgraded from 8.6.16 to 8.7.3 the calendar display is blank. All the json information displays in the view preview, and using console.log I can see the information load on the page. I can load events in a normal view without any issues. I've spent several days trying to figure out what change may have caused this, my leading theory is that something with date formatting may have changed somewhere, but so far, no luck. Does anyone have any documentation about a date format change between Drupal 8.6 and 8.7?

EDIT: I just noticed the difference by exporting the views preview and running a diff on them. The live site displays dates correctly like this "value":"2019-06-27T00:30:00 while the updated dev site displays dates like this "value":"2019-06-26T17:30:00-07:00" so could something have changed with time zone translations or date fields that is interfering with our code?


texts:
I'm having some problems with sending e-mails from my drupal site.
It was working just fine before.

Some information:

The site is using webforms so I checked the issues here: http://drupal.org/node/344668
None of them solved the problem.

The server recently upgraded to a new version of litespeed (maybe this is relevant?)

The site is also using the STMP Authentication module.
It's using the gmail smtp: smtp.gmail.com
Running on port 587 (so with TLS enabled)
Authentication is required and correctly filled in.

Both e-mail addresses are filled in (the default server e-mail address and the e-mail address used by SMTP auth.), both of them are correct addresses in the form of info@sitesdomain.com .

The recent logs show 3 messages:

Sending mail to: my@emailaddress.com
Error sending e-mail from site e-mail address : SMTP error: Could not connect to SMTP host.
Error sending mail from site e-mail to my e-mail address.

The drupal version is 6.2, webforms version is 6.x-3.2 and stmp auth version is 6.x-1.0-beta5

I've checked the STMP Authentication Support issue queue but there are no relevant item there that can help me. And if there are, then there are no answers.

I don't know how to take a look in the stmp log. I wouldn't know where to find it.

Any help would be appreciated.

Thanks,

Mike


texts: How do I redirect users from the registration page to Paypal?

texts:
Only users with a "Sign Up Code" are allowed to sign up to the website. If they provide a valid signup code, they will be directed to a sign up page where they can provide user information, and PayPal processing is used to process the fee. On completion of payment an account is created.

How can I redirect user to Paypal?
How can I check the payment is paid by user?
How can I create the account if the user paid?


texts: Ajax Search Field with labels for node types

texts: I'd like to have a search field with ajax and some kind of label for the node type. Similar to http://www.finanzen100.de . Is there any module or other ways of getting this for drupal 7 (or 6)?


texts: How to display blogs related to particular taxonomy term name

texts:
I am creating blogs in my site. I have categorized the blogs by using taxonomy terms. I want to display these category names in right side view as a block, and when user clicks on the name, views should display related blogs to the user.

I tried by using contextual filter but its showing content title not the taxonomy term names, as you can see in the above image right side block.
Below images shows the contextual filter settings i tried.

So please help me regarding this.


texts:
I have two simple content types

Parent
Child

The Parent content type has an unlimited value entity reference field which allows it to reference Child nodes.

The Parent content type Manage display for the Child entity reference field is set to "Rendered entity".

Now when viewing a Parent node, each of its Children nodes are displayed as well. Great.

However, I'd like to see an "Edit" link next to each Child node when viewing a Parent node. How can I achieve this? I'm hoping for a hover feature that would pop up a cog icon.

I thought the "Show links" option on the field's display settings would show some type of link(s), but it appears none are showing.


texts:
I am udating an existing website from Drupal 7 to 8. The original developer placed most of the theme/items into Module Features (like a front page slider). I have about 37 Features that I need to move into Drupal 8.

I can get into the .info file and change some of the elements to be .yml compliant but there are feature variables included that I don't know how it should be coded.

Files are located in sites/all/modules/features/ without about 8 categories (blocks, configurations, content_types, core, forms, menus, nodequees and views) and multiple features under each category.

Example of one feature's .info file

# cat sites/all/modules/features/content_types/cf_content_types_homepage_slider/cf_content_types_homepage_slider.info
name = MySite Features: Content types: Homepage slider
core = 7.x
package = MySite Features: Content types
dependencies[] = cf_core_field_bases
dependencies[] = ctools
dependencies[] = features
dependencies[] = image
dependencies[] = link
dependencies[] = picture
dependencies[] = strongarm
dependencies[] = text
features[ctools][] = strongarm:strongarm:1
features[features_api][] = api:2
features[field_instance][] = node-homepage_slider-body
features[field_instance][] = node-homepage_slider-field_background_image
features[field_instance][] = node-homepage_slider-field_link
features[field_instance][] = node-homepage_slider-field_small_image
features[node][] = homepage_slider
features[variable][] = comment_anonymous_homepage_slider
features[variable][] = comment_default_mode_homepage_slider
features[variable][] = comment_default_per_page_homepage_slider
features[variable][] = comment_form_location_homepage_slider
features[variable][] = comment_homepage_slider
features[variable][] = comment_preview_homepage_slider
features[variable][] = comment_subject_field_homepage_slider
features[variable][] = field_bundle_settings_node__homepage_slider
features[variable][] = menu_options_homepage_slider
features[variable][] = menu_parent_homepage_slider
features[variable][] = node_options_homepage_slider
features[variable][] = node_preview_homepage_slider
features[variable][] = node_submitted_homepage_slider

Now I know some of the changes that need to be done for YAML such as changing the "=" for ":" and listing the dependencies.

I also know that 'strongarm' is now included in the Drupal 8 core.

name: 'MySite Features: Content types: Homepage slider'
core: 8.x
package: 'MySite Features: Content types'
type: module
dependencies:
  - cf_core_field_bases
  - ctools
  - features
  - image
  - link
  - picture
  - text

But then I'm stuck.  I have only done some but even those

I don't see them in the list of Modules or Feature Bundles
I don't know how to reference all the features variables

I do not have experience with developing Features (didn't even know about them until now) or developing Modules.

Are there any good sites on how to convert a Feature from D7 to D8?  I know about articles saying don't use Features in D8 but I need to get this site updated and don't have time to rebuild everything from scratch (even if I knew how to make all these capabilities work in a new site).

Any good sites to go over how Features work?  Maybe if I learn the details of how these features were built I could understand how to change them over?

Any help?


texts: How do I delete old nodes (with attachments) after running cron?

texts:
I've site on Drupal 8.1.x with many nodes (over 200). That node type is articles. Some nodes are old (written last year, for example) and have non actuality content with attach files (photos).

How to make easy way to delete old (older than 30 days from today) nodes of one type (name articles) with all attachments (photos) after run Drupal Cron (for example, time to run Cron is every week)?

Write custom module or use hook_cron() or something else?

Any working examples helps me to understand. Thanks!


texts: Twig template variable not displaying value

texts:
I have a Twig template for a custom block. My custom module is establishing what template is used like so

function mymodule_theme($existing, $type, $theme, $path){
    return array('mymodule' =>
        array(
            'variables' => array(
                'header-title' => 'Default Title',
                'header-size' => 'h1'
                ),
                'template' => 'block--HeaderText'
            )
        );
}

and my custom block contains.

public function build() {
    return array(
        '#theme' => 'mymodule',
        '#title' => '',
        '#header-title' => $this->configuration['label'],
        '#header-size' => $this->configuration['header-size-submit'],
        );
}

And in my block--HeaderText.html.twig I have

<h2>{{ header-title }}</h2> This is a test {{ header-size }}
{{ dump() }}

However header-title and header-size both output 0. But using the dump() function in the template shows that the actual variables are available some how.

The dump() produces

array(15) { ["header-title"]=> string(19) "Header Textsdfgsdfg" ["header-size"]=> string(2) "h4"...

Yet {{ header-title }} just results in 0.


texts:
I am using workflow module to manage article moderation. I have created different state for that and for each state, I have set permissions using workflow content access.

Now, when an article is flagged, I am changing it's workflow state to say "s1" and unpublished the content.

In this state, author's can allow to edit the content but not publish it, the edited content will be sent to admin for review.

Now when I go to edit tab, it is showing "Publish" button too, by which author can Publish the content.

How can I remove these buttons ? Also is there any way, I can show workflow comment box in edit node page only.

-- Many thanks for your time.


texts:
I know with Drupal you can have threaded comments. I wish to create something similar using nodes.

Where a node can be replied to with a node of the same type. I would then like to try and create a view of this. Do you think this is possible or should I look at bending comments to be more like nodes.


texts:
I'd like to use placeholders instead of labels for a form built with the form API.

I can get placeholders working well with the Elements module, but now I want to hide the labels. If I just set ['#title'] = NULL; then form errors don't have descriptive names, and it ruins accessibility.

In Drupal 7, you could set the #title_display to invisible (documentation). Was something like this backported in a contrib module somewhere?

Or is there a way I can set my own class on the label element?


texts:
I am trying to dynamically display boolean fields into columns based on their value.  So for instance these 10 boolean fields on my node, if marked 1, I want it to theme it so that they show up in a column to the left titled Completed, and if marked 0, a column to the right titled Not Complete.  I have tried using template.php and field.tpl.php but I am getting very lost.

I'd like to do this on the field node being viewed (not using Views) as a custom dynamic field formatter that applies a different css class to the field div.  That or in the theme layer using some php magic.


texts: Drush not working on Multisite with Shared User Table

texts:
I have a Drupal 7 Multisite Environment with sub-directories.

(E.g):

mainsite.com
mainsite.com/multisite1
mainsite.com/multisite2
mainsite.com/multisite3
etc.

Each website has its own Database and all are on the same Database Server

I recently configured the multisites to have a Shared User table along with a few shared custom User fields and that aspect works.

However, I am now unable to use Drush within the Multiste directories.

Previously, I would CD into the directory and be able to run Drush commands for that specific multisite like this:

cd /var/www/mainsite.com/sites/multisite1
drush cc all

Now it tells me that "No Drupal site found".

When I comment out the prefix portion of my settings.php file, Drush works again.

How can I make Drush work for these sites?

Below is what my settings.php file looks like:

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => '[Multisite DB]',
  'username' => '[Database Username]',
  'password' => '[Database Password]',
  'host' => '[DB Server IP]',
  'charset' => 'utf8mb4',
  'collation' => 'utf8mb4_general_ci',
  'prefix' => array(
        'default'   => '[Multisite DB].',
        'users'     => '[Main Site DB].',
        'sessions'  => '[Main Site DB].',
        'role'      => '[Main Site DB].',
        'authmap'   => '[Main Site DB].',
        'users_roles'   => '[Main Site DB].',
        'field_data_field_first_name'   => '[Main Site DB].',
        'field_data_field_last_name'   => '[Main Site DB].',
        'field_data_field_title'   => '[Main Site DB].',
  ),
);


texts: Is it posible to show the selected data under the map also? When i enable "københavn" as show at the picture, then there should be a list of resturants downunder also?