texts: How to reconnect after MySQL Server gone away error

texts:
I have long running CLI script which crashes down sometimes because of:

  MySQL Server gone away

#inside loop
$content = null;
while ($content == null) {
  try {
     $content = getContentFromMysql();
   } catch(PDOException $ex) {
     #What to do here?
   }
}
#do something long with fetched content

What should I write in the catch clause? (I am using standard Drupal DB API)

EDIT

Since error happens when I try to select data I write my own wrapper class (I am using MSSQL as main db, so I can messed up Mysql driver):

class JoomlaDatabaseConnection_mysql extends DatabaseConnection_mysql {
    public function select($table, $alias = null, $options = null) {
        self::openConnection('joomla', 'default');
        return parent::select($table, $alias, $options);
    }
}

But know how to tell Drupal to use this class?

:/

  final protected static function openConnection($key, $target)

shame not public, but I understand why.

Thanks to @karthik advice I am testing solution with ini_set.

Another solution for altering database access class is to create new driver:

Create directory of driver name (e.g. mysqlJoomla) in includes/database
copy standard mysql driver files from includes/database/mysql
change database.inc file content to e.g.:

class DatabaseConnection_mysqlJoomla extends DatabaseConnection_mysql {
 public function select($table, $alias = null, $options = null) {
    parent::openConnection('joomla', 'default');
    return parent::select($table, $alias, $options);
 }
}

add new driver info:

$joomla_url = array(
 'database' => JDB,
 'username' => JUSER,
 'password' => JPASS,
 'host' => JHOST,
 'prefix' => 'jos_',
 'driver' => 'mysqlJoomla',
);
Database::addConnectionInfo('joomla', 'default', $joomla_url);

EDIT

Oops I see I can't use

  openConnection

method inside driver class because it is method from Database class :/

It is a big problem in DB API. Programmer should has chance to reconnect (calling openConnection()) by using inheritance.


texts:
I'm building an international site and am running into trouble with the language detection. I need to have urls structured like the below examples for SEO purposes, but nothing I've found will allow for that. I wrote a little module that hooked into pathauto to prepend the code to the alias, but it didn't seem to be recognized... I'm using Organic Groups and Domain Access to manage the multiple countries, and Entity Translation and i18n for the languages. I also have Global Redirect in place to help keep out duplicate content links.
One requirement is that for some countries the default language should not be prefixed at all.

Has anybody had experience with urls like this? It seems like it should be possible without hacking into the core...

Country     |   Language    |   URL

Austria     |   German      |   www.domain.com/at
Belgium     |   Dutch       |   www.domain.com/nl-be
Belgium     |   French      |   www.domain.com/fr-be
Canada      |   English     |   www.domain.com/en-ca
Canada      |   French      |   www.domain.com/fr-ca
........
Global      |   English     |   global.domain.com/en
Global      |   French      |   global.domain.com/fr


texts:
So I tried this tutorial on Taxonomy Menu and Menu Block. Now I set up the block to go in the header showing only 1 level deep.

My goal is to click on that 1 level deep link and generate a second menu showing the hierarchy. Instead I get a generic template that displays all posts of the parent taxonomy.

So, ideally:

[Header Menu Item] > Goes to hierarchy tree

Sub category 1 > Goes to hierarchy tree

Nodes of sub category 1


texts: How to use Exposed Filter criteria form for Advanced forum

texts:
I'm trying to modify my Advanced forum topic list Master view to have an exposed filter so that my users can search for topics.

However, after even a clean install with simplytest.me gives me the same problem: while entering a search query into the exposed form, the user will be redirected to the front page.


texts: Email users on node creation based on taxonomy reference

texts:
I have 2 taxonomy vocabularies (town and topic) which are referenced on both a user and a node. When a node is created, I need to email all users who are referencing any of the terms referenced on the node EXCEPT when the node has been directly assigned to a user (using a User Reference field).

The Subscriptions module works great for notifying users of all new nodes with a particular term, but I cannot find a way to exclude nodes based on other fields (in my case, the User Reference).

I can use Rules to send an email when a new node is created without the User Reference, but I don't know how to define the recipients as "all users with a referenced term which is also referenced on the new  node". VBO may be the answer, but I'm lost on how to generate the View from Rules.

Any suggestions? Thanks.


texts:
I have have a content type (Stuff) with an entity reference field (comments) for comments (their type is Stuff comments) with a single field (comment_body).

Inside a controller, I loaded a node by its ID.

How do I get the list of all the comments for that node?


texts: Background of CKEditor is black for authenticated user

texts:
I am using the CorporateClean theme for Drupal 7.15, and I have an issue using CKEditor with this theme.

When an authenticated user writes some content, the background of the CKEditor text editor (the area where the user can enter and format text) turns black. I do not have this problem when login as the admin. I also do not have this problem if I remove CKEditor.

How can I change this background?


texts: Where are the Page Manager "Caching options"?

texts:
In D7 I'm using Ctools, Panels (3), Views, Page Manager etc., but in Page Manager when gear-icon-clicking the content panes I don't find any "Caching options" as I have seen described. What reasons can there be for this.
It's probably something really simple, I just can't find it...


texts: Trouble populating text field widget while executing node.create through Service using Rest server

texts:
I have a Rest server running using the Services module which is setup to receive node and user requests.  I have also created a new content type with the following fields:

I am able to add new instances of this content type using Poster (a Firefox plugin for creating http-post requests) using an http-post to my rest server with the following body (using application/json content-type):

{
  "title":"online submission",
  "type":"basic_content",
  "field_text":[
    {
      "value":"Some Text"
    }
  ]
}

I have tried many different variations of this json string (including make it all one line) and it never seems populate the text field.  Could anyone shed any light on this?  I am willing to use a different content-type if necessary.


texts:
I'm using Drupal 7 along with the Panels and Views modules. I've got a view with a page display, but I want to place it in a panel/page. I need the view's display to be that of a page because it has exposed filters, and I can't rely solely on AJAX for the filters because of 508 standards compliance concerns.

However, because the paths of the panel and the view are the same, the view takes precedence, and the panel never shows up. How do I get the view working inside the panel?


texts: How I can connect a menu link with a LINK that exists in an another menu link?

texts: I have a menu link menulink2 that when clicked goes to admin/bla/blabla. I have also another menu link menulink1 that do not go nowhere. Now I want menulink1 when clicked to go on the same link that menulink2 goes... Any ideas?? I suppose it will be with menu_alter..


texts: How do I deal with discounts/refunds and a payment gateway to achieve accurate reporting for accounting?

texts:
First off, this seems like a fairly basic function required for ecommerce.

I was presented with a question today:

  "Will our new website give reporting so accounting can be done from within the website?"

The answer: "Yes! With Commerce Reporting module and Views."

Then came the followup question:

  "Great! So we will be able to add partial refunds, full refunds and discounts to existing orders within the site, have our payment gateway (PayPal) receive the discount/refund requests and have all of this show up in our reporting exports?"

The answer to that: "UMMMMMMM........"

Simple example: Customer purchases two items. Item #2 was a mistake. Customer requests a refund via good old fashioned email. We are presented with a question: Does the refund get issued from within Drupal Commerce or within the payment gateway?

What are the solutions for dealing with this?

Does the company still have to rely on the payment gateway (and its ever-changing, unstable export features) for reporting? If so, how does Drupal account for any changes made to an order (i.e. refunds, manual discounts)?

If not, how do I set up Drupal Commerce to get the reporting accurate to include refunds and any line item price corrections?


texts: Using the Feed Import module, I can not map for “address field”

texts:
I use the Feed Import" to import nodes. The other fields were OK, but I cannot map the address field provided by the Address Field module.

I edited the feed, used "Enter field name," and set to "FIELD_CONTACT_ADDRESS: LOCALITY," but it doesn't work.

I also tried "FIELD_CONTACT_ADDRESS:LOCALITY," "FIELD_CONTACT_ADDRESS_LOCALITY," "FIELD_CONTACT_ADDRESS-LOCALITY," but they don't work.


texts: drupal 7 views contextual filter base path

texts:
I am using drupal 7 views, I try to use contextual filter, and I noticed that there are 3 base path with a textfield in section "When the filter value is NOT available"

I am confused and not sure what should I key in for that.

Please advise. Below is the screenshot as an example.

I have uploaded the screenshot but not allow to publish due to reputation less than 10
http://i.stack.imgur.com/5KsEr.png


texts: How to change the numbering in duplicate path aliases?

texts:
All my node paths have a URL alias, provided by Pathauto. The pattern is [node:title]. The generated aliases for nodes with the same title are by default

title,
title-0,
title-1,

etc. I would like to change this numbering into

title-1,
title-2,
title-3,

etc. So, when a node with the title Test is submitted, a URL alias test should be generated. Once a second node with the same title is published, another alias test-1 should be created for the first node and a new alias test-2 should be added for the newly created node.

How can I do that?


texts: How can I get all related entities of a node programmatically?

texts:
I am writing some drush scripts and find myself needing to get related entities (nodes) of the current node. However I can only find info for constructing views that do this.

Can anyone tell me is there a programmatic way to pull all entities that relate to the current nid with a filter on the entity type?

Ultimately I need to get a list of node ids that relate to the current node id.

The relationship depend on the relation module.


texts: Hook for module activation and deactivation

texts: I am trying to execute a function in my module when the module is activated or deactivated by the user. It seems that there is a hook for this in Drupal 7, but not in Drupal 6. It is possible to do this with a workaround in Drupal 6?


texts: Using rules to grant new role upon visiting page

texts:
Using the modules "rules" and "rules linkevent" I am trying to get drupal to automatically assign a new role to the user upon visiting a certain page.

I've written it like this/entered the following values and selected these options:

-

Events Event
levelup2 was accessed

-

Conditions Elements

User has role(s)
Parameter: User: [site:current-user], Roles: authenticated user

-

Actions Elements

Add user role
Parameter: User: [site:current-user], Roles: Level 2

What am I doing wrong or how could I alternatively make the user accessing the page, reading the page or another trigger I can make be granted a new role?

I have tried searching the net but have found no answers.
Can anyone help?


texts: Creating new content redirects to PAGE NOT FOUND

texts:
When I create content, regardless of the content type, I am redirected to a page not found error message even though the page is created. Can you please help? I got this message:

Page not found Add URL redirect from this page to another location The requested page "/node/5191" could not be found.   This happens regardless of the content type. I can't figure out what is going on.


texts: Display Member Count along with Group Name

texts: How can we Display the individual Member Count along with Group Name in Group Listing Page through View option.


texts: Alert after form radio has been selected

texts:
I am trying to use drupal ajax to test if an email address from the form it is in my database. For that i have altered the form and added the following line to the element:

   $form['field_radio']['#ajax'] = array
    (
       'callback' => '_get_member',
       'progress' => array('type' => 'throbber', 'message' => '')
    );

and the callback function:

function _get_member($form, $form_state){

     $sid = $form_state['values']['details']['sid'];
    $commands[] = ajax_command_alert("Hello World");

    return array(
    'type' => 'ajax',
    'commands' => $commands
  );
}

As you can see from the callback i just want to return an alert message but it does not work. The callback is called because i have tested using watchdog but the alert popup never fires. Why ?


texts: How can I make a slideshow with tabbed navigation/menu?

texts:
I'm trying to make a slideshow that looks something like this

I'm using views slideshow but I could change it up if need be. Preferably views though.

My problem is the navigation to the right. I have created a content type for this slideshow and fields for the image, the green title and the black subtitle. The slideshow should run by itself and highlight the proper menu item in the sidebar, but also allow for the user to change slide by clicking a menu item.

Any ideas on if and how this could be done?


texts: "PHP Fatal error: Call to undefined method Consolidation\AnnotatedCommand\Hooks\HookManager::getHookOptions()"

texts:
I just installed drush using "composer require drush/drush". It ran correctly and when it completes a navigate to vendor/drush/drush/ directory where the drush.php file is located

Then I run the following command:
php drush.php status and I get the following error:

PHP Fatal error:  Call to undefined method Consolidation\AnnotatedCommand\Hooks\HookManager::getHookOptions() in
[...]/work/www/EnviePractice/vendor/drush/drush/includes/annotationcommand_adapter.inc on line 475
PHP Stack trace:
PHP   1. {main}() [...]/work/www/EnviePractice/vendor/drush/drush/drush.php:0
PHP   2. drush_main() [...]/work/www/EnviePractice/vendor/drush/drush/drush.php:12
PHP   3. Drush\Boot\BaseBoot->bootstrap_and_dispatch() [...]/work/www/EnviePractice/vendor/drush/drush/includes/preflight.inc:66
PHP   4. drush_dispatch() [...]/work/www/EnviePractice/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php:67
PHP   5. annotationcommand_adapter_add_hook_options() [...]/work/www/EnviePractice/vendor/drush/drush/includes/command.inc:170
Drush command terminated abnormally due to an unrecoverable error.                                                                      [error]
Error: Call to undefined method Consolidation\AnnotatedCommand\Hooks\HookManager::getHookOptions() in
[...]/work/www/EnviePractice/vendor/drush/drush/includes/annotationcommand_adapter.inc, line 475

Can anyone please guide me to what might be causing this?

Additional details:

I am on ubuntu 16.04
Drupal 8 installation
version of drush 8.1


texts:
I am using drupal 8 and webform 8.x-5.0-beta25. I have a multistep form with ajax enabled, 5 pages.

I need to alter the confirmation message but I haven't been able to figure it out. What I want to achieve is change the message depending on some form values the selected on the last question. I've created a custom module and extended the WebformHandlerBase and created a confirmForm function but I am not seeing anything once the form is submitted.

Again, it is submitting through ajax so I am not sure if that has anything to do with it.

Here is what I have tried so far

/modules/custom/cbed_ux/src/Plugin/WebformHandler/QuizWebformHandler.php

<?php
namespace Drupal\cbed_ux\Plugin\WebformHandler;

use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform\WebformInterface;
/**
 * Form confirm handler.
 *
 * @WebformHandler(
 * id = "quiz_handler",
 * label = @Translation("Quiz Handler"),
 * category = @Translation("Quiz Handler"),
 * description = @Translation("Quiz Webform handler."),
 * cardinality = \Drupal\webform\WebformHandlerInterface::CARDINALITY_UNLIMITED,
 * results = \Drupal\webform\WebformHandlerInterface::RESULTS_PROCESSED,
 * )
 */
class QuizWebformHandler extends WebformHandlerBase {
  public function confirmForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
    kint($webform_submission);
    drupal_set_message ('submitted!!');
  }
}

The form submits, but I do not see my kint or set message


texts:
I have two Drupal website setups. One is development and another one is live. In my live setup lot of comments are there. I want to export all comments and import to development setup.
How can I do that?


texts: D8 How to create custom configurational form translatable?

texts:
I am new to Drupal 8 Custom Translation.
I am working on a custom module with a backend form from where user can add some textual inputs.

The Site is multilingual, so I need to have this backend form translatable.

May I know the steps or any links from where I can get an idea where to start for translatable configuration form/page where user can add textual inputs for each languages.

Thanks in advance.


texts:
How is it possible to create simple confirmation popup dialog boxes in Drupal 7?

I've searched a lot, but I found tons of non-working suggestions and code.


texts: Can you change the view item output amount depending on user role?

texts: Is there a way to do this within one view/display or do I have to make two seperate displays, one showing field_images with unlimited item output and one display showing field_images but only showing max 2 images - depending on user role?!


texts: "_blank" target attribute for links in views

texts:
I have a custom view that lists a specific content type. I have fields output for each node and have set them to "Link to: Content".

Simply, is there a way to now set the target to "_blank"?

If you are "Rewriting Results" you have the option to specify the target attribute, however I am not rewriting the result (this requires a separate declaration of link path).


texts: Import nodes programmatically without administrative access

texts:
I have a database of drupal installation, containing around 300 nodes. I need the nodes from  that database to be added into another Drupal installation. How can this be done programmatically?

I have only a SQL file, and I don't have administrative access to the Drupal installation.


texts:
I've recently started working with Drupal 8. I'm looking for a way to programatically(no drupal console or other CLI thing) get a list of all the services available.

Since it's built on top of Symfony I figured that the container should have a list of all the available services. Well, I was wrong.

I've searched around and I can't find any specific answers, other than the CLI option, which is not what I'm looking for.

If anybody can point me in the right direction here, I'd be grateful.


texts: How to theme Profile 2 fields for anonymous?

texts:
I bring this question because I am not able to find the answer in anywhere, my apologies if it is a repeated one.

I have a Profile 2 type "curriculum_vitae", that I use to gather jobseekers CV.

I have all the Jobseeker's CVs  available for anonymous users which is working fine. My question how to theme the jobseeker's CV page "The page that will display to anonymous user once they click at the jobseeker profile".

I have a page named "profile2--curriculum_vitae.tpl.php" located at "\templates\profile2--curriculum_vitae.tpl.php".

I want to theme every single field of curriculum_vitae profile.

For example :

Email:
Here I want to print jobseeker's email in here, the filed machine name is "field_cv_email_address"


texts: Submit button calling wrong submit handler

texts:
I have a form with 3 different "Submit" buttons, and I want each of them to map to a particular Submit handler.

I have included these items using the following, generic, pattern:

                    array(
                        '#prefix' => '<td>',
                        '#suffix' => '</td>',
                        '#type' => 'submit',
                        '#value' => 'Update',
                        '#submit' => array('user_profile_details_edit_phone_submit')
                    )

But, every time I click the "Submit" button, the incorrect function is called. The function that IS called is the LAST function I add to a submit handler in this way.

Am I doing something wrong?


texts: How to split and link date field to view (imdb style)

texts:
I have created content type call person (list of persons)
added a date field to content type (birth_date)

how to split date to year/month (or should it be two date fields)
how to link year to all the people born on that year and month/day to all people born on that day. I know how to create view, but how to make date output as link to it?

Pretty match like imdb does it, not display calendar but text in one line.
birthday: year[link]/ month day[link]


texts:
I need to use MariaDB instead of MySQL in Drupal 8. I have already installed MariaDB in my local system.

How do I use it with Drupal 8? What changes are required to use it?


texts: Views Filters: show published items from the last week or minimum number of items

texts:
The homepage on our local newswebsite "Zee-Online" has a view that shows al published content from the last week. How can i change this, to show at least a fixed number of items?

I want a view that gives me all the nodes from the last week OR at least 12 items (if the first filter-criteria doesn't result in at least 12 items)


texts:
I created a custom template and by mistake i chose my template as a adminpanel template.

that got rid of the dashboard. how change the template to default template.


texts: Error in drupal_form_submit when taxonomy reference (tid) is set

texts:
While trying to creating a node programmatically using 'drupal_form_submit' i've come across a php error in the form.inc code

Here's my code

function vl_sample_data_generate_yvbct1() {

  module_load_include('inc', 'node', 'node.pages');

  global $user;

  $content = 'Generating YVB CT1';
  $form_state = array();
  $data = array();
  $node = (object) array(
    'uid' => $user->uid,
    'name' => $user->name,
    'type' => 'yvb_ct1',
    'language' => LANGUAGE_NONE,
  );
  node_object_prepare($node);

  $data['uid'] = $user->uid;
  $data['created'] = time();
  $data['type'] = 'yvb_ct1';
  $data['language'] = LANGUAGE_NONE;
  $data['title'] = 'Node created on ' . time();
  $data['status'] = 1;
  $data['op'] = 'Save';

  $data['field_middle_name'][LANGUAGE_NONE][0]['value'] = 'Alex';
  $data['field_gender'][LANGUAGE_NONE][0]['tid'] = 24;

  $form_state['values'] = $data;

  drupal_form_submit('yvb_ct1_node_form', $form_state, $node);

  return $content;
}

The error i get when i run the function (as a menu callback) is

Warning: Illegal offset type in isset or empty in _form_validate() (line 1333 of /opt/httpd/htdocs/www/staging/jns/trunk/includes/form.inc).
An illegal choice has been detected. Please contact the site administrator.

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 173 of /opt/httpd/htdocs/www/staging/jns/trunk/includes/entity.inc).

Warning: Illegal offset type in taxonomy_field_validate() (line 1519 of /opt/httpd/htdocs/www/staging/jns/trunk/modules/taxonomy/taxonomy.module).

Notice: Trying to get property of non-object in taxonomy_field_validate() (line 1519 of /opt/httpd/htdocs/www/staging/jns/trunk/modules/taxonomy/taxonomy.module).

However, if i comment out the line

  $data['field_gender'][LANGUAGE_NONE][0]['tid'] = 24;

It works fine. Am using Drupal 7.26.
Also, the term tid does exist and belongs to the valid Vocabulary which is
assigned in the content type.

Any help regarding the above problem is appreciated.

Thanks

Yashesh


texts: Not able to access "Updates" page logged in as admin user

texts:
I am running a site on Acquia's dev cloud, using Acquia's Dev Desktop and sometime in the last few months something has changed to prevent access to the Update tab inside admin/modules/update. I'm logged in as the drupal admin, but when i try to access that page i get:

  You are not authorized to access this page.

Also on that page, cron had stopped running regularly. When I tried running manually, it would give me the same error


texts: Configure Facets to drill down one level at a time

texts:
I have vocabulary ("Subtype") hierarchy like this...

CP

LP

ML
U

BL

FL
AD

MA

PD

OPD
SG

I have a field on my entity type field_subtype.  What I'd like is to configure my search api and facet to when, for example, on the homepage, only show

CP
PD

If a user clicks through to CP, only show

LP
BL
MA

And so on.
I have gone through a mess of configuration trying to get this to work, ending up with results that will either show level 1 (CP, PD) or level 3.  I think this is because no content is directly tagged with items such as LP, BL, MA but I can't be certain.
For the search API side of things, I've added the subtype field, tried drilling into it to add the tid only, etc.  Then within the facet settings I've tried choosing the different fields to see the results, but I'm never getting what I expect.
I feel like this is something that should just work and that I'm goofing it up somewhere.  How do I configure my search api fields and facet settings to work in this way?
EDIT
It might just be as simple as missing the Index Hierarchy in the processor tab.  I'll post as an answer if/when I confirm.  I checked this several times but, somehow, I apparently missed the Subtype (other fields are configured).


texts: How do I recreate the system.site configuration element?

texts:
For some reason system.site, system.performance and system.date config values have been deleted from our site.

I have the original configuration files, but when attempting to import those using drush cim, Drush complains about the site UUID mismatch.

The import failed due to the following reasons:
Site UUID in source storage does not match the target storage.

I assume this is because UUID is missing entirely. If I run drush cget system.site, I get the following error:

[error]  Config system.site does not exist

Attempting to set the UUID with drush config-set "system.site" uuid "my site id" also fails with:

[error]  Config system.site does not exist

So now I'm in a bit of conundrum.

Any suggestions on how to restore the system.site configuration?


texts: Any way to have "Path Will Be Viewed" trigger?

texts:
I would like to restrict certain roles from visiting certain pages, ideally by using Rules.

I am able to do this with Nodes, however for Pages such as a Views Page, I can't see any way of triggering this redirect?


texts: Problem attaching files to nodes with Services

texts:
I'm trying to attach files (images) to nodes via Services 3 from an external app using JavaScript.

From what I understand (and doing) is:

1) Create a node posting JSON to my endpoint domain.com/api/node.json

{
  "type":"foo",
  "title":"Hello World",
  "language":"und",
  "body":{"und":{"0":{"value":"Body Text"}}},
}

2) Create file posting JSON to my endpoint domain.com/api/file.json

{
  "filename":"image.jpg",
  "target_uri":"public://image.jpg",
  "filemime":"image/jpeg",
  "file":"myBase64String"
}

No problem at all at this point.

Then when trying to attach the files created to the node, is where I have trouble, not http errors, simply nothing happens.

First I have tried posting JSON to my endpoint domain.com/api/node/*nid/attach_file after successfully creating a new file, and getting back the fid

{
  "field_name":"foo",
  "filename":"image.jpg",
  "fid":"*fid"
}

Returning Status 200 OK empty text, but when viewing the node remains the same without the file attached.

I have also tried to create the files first and then when posting for node creation adding the fid, the node is created but no file attached.

{
  "type":"foo",
  "title":"Hello World",
  "language":"und",
  "body":{"und":{"0":{"value":"Body Text"}}},
  "field_foo":{"und":{"0":{"fid":"*fid"}}}
}

My field is a field type Image, widget Image. I have also tried in another field type file, with same results.

If someone can give me a heads up, what am I doing wrong or what is missing. I can't find any explanatory documentation on line.

Thank you.


texts: Allow people to administer only on certain content type?

texts:
Under "admin/people/permissions" there is a permission that allows users to administer all the content types.

I want to create a role that can only administer an "Article" content type.
How can I achieve this?


texts: drupal 7 template suggestions based on path alias

texts:
I am using this function on a D7 site to template based on url alias and everything works except when a page has a dash in it.
For example mysite.com/test-page doesn't work. I tried page--test-page.tpl.php and no luck. If I change to testpage and use page--testpage.tpl.php it works.
Any ideas?

Here is the function that works:

function mytheme_preprocess_page(&$variables) {
    // Get the alias for the page being viewed
    $alias = drupal_get_path_alias($_GET['q']);
    if ($alias != $_GET['q']) {
        $template_filename = 'page';

        //Break it down for each piece of the alias path
        foreach (explode('/', $alias) as $path_part) {
            $template_filename = $template_filename . '__' . $path_part;
            $variables['theme_hook_suggestions'][] = $template_filename;
        }
    }
}


texts:
Been trying to add a custom error notice with jquery, but so far the div looks funky

jQuery('h1').prepend('
Start
');

Any tips how to get this to work? As I understand Drupal uses the error div.


texts: HIde taxonomy menu based on count? Possibly using rules?

texts:
Is it possible to hide taxonomy menu items based on their node count?

E.g. i have several zounds categories (notebooks, office, health, etc) created but they are just empty taxonomy items because the client has yet to add these products.

I'd like only the taxonomy terms with nodes to be visible.

Is it possible to accomplish this via rules or some other module?

Background:

I have a taxonomy menu created by taxonomy_menu and then it's turned into a menu block and that menu block is turn into a superfish dropdown menu.


texts: How do I resolve feature conflict for two different content types?

texts:
Possible Duplicate:
  How do I resolve this conflict between two Feature modules?

I have created two content types content type A and content type B. Then I have added 3 fields to content type A(Node reference of content type B, Taxonomy and tags) and 2 fields to content type B(Taxonomy and Tags). When I am creating two different features for content type A and Content type B. It is showing conflict but when I am creating a single feature for both content types no conflicts.


texts: Could drush require significantly more memory than same action in Drupal

texts:
I am running Drupal 7.23 and drush 5.9

I can clear all caches in Drupal without an error but get "memory exhausted" if I try using drush cc all. I get "memory exhausted" when using "drush up", after it has downloaded and updated modules but was able to download and update the modules from within Drupal.

Is there anything that might be leading to a greater need for memory when using drush?


texts: Why did removing a feature only removed part of the functionality (not flags?)

texts:
I just removed a Feature module (a module created by Features) from my site and I discovered that some of the functionality that the module added is still present on the site.  Specifically, two flags are still available on their designated content type.  Here is what I did:

I created a feature module which contained two flags, two menu items and a view.
I uploaded the feature module to my test site
I activated it via check-box at Home › Administration › Structure > Features
I verified that all functionality was added
I deactivated it via check-box at Home › Administration › Structure > Features
I attempted to verify that the functionality was removed.
I discovered that the two flags still existed on their designated content type.

Did I miss a step or are flags not removed when a feature is disabled?


texts: What does Drush error "Unknown option: --db-url" mean?

texts:
Somehow user 1 has become blocked on a Drupal site I manage.   As a result, I can't issue a uli command via Drush.  I tried to use the command

drush @pantheon.xxxxxx.dev user-unblock --uid=1

but it returns error

Unknown option: --db-url.  See `drush help user-unblock` for available options.

I have checked the help for user-unblock for but it does not mention --db-url.  The site is working and and other users can log in, however I can't get in as admin.

Thanks.


texts:
I have several select fields in content type, which is more like Q/A & most of the answers are YES/NO. It's like tree flow, all question are dependent upon answer of previous question.

I am using condition fields & field conditional state module for this purpose. OR can be implemented by help of FIELD CONDITIONAL STATE as module description says --

Module supports AND/OR functionality for control fields which means:

    AND - all choices must be selected to control the filed
      (example: field A will be visible when in field B option 1 and option 2 is selected)
    OR - any choice will control field
      (example: field A will be visible when in field B option 1 or option 2 is selected).

But I have some fields(e.g. Field C) which should be appear on selection of YES of Field A or NO of Field B.

Is it possible to achieve it by this module or some other way by any contributed module. I am not looking for making my own form by FORM API as I have around 60 question in content type & it will become so messy to manage in code.

Edited --

I have searched & got option such as using OR in conditional field in this manner-

field_atleast_50_capital is visible when field_property_deriving has value "No".
OR
field_atleast_50_capital is visible when field_arrangements_90_subsidiary has value "Yes".

But it doesn't work..


texts: Editing a Field Collection element in a custom module

texts:
In a custom module, I'd like to to edit a Field Collection element. The element is linked to a taxonomy but I think the code would look quite similar if it was to a content type.

I've read a lot of documentation, source code, forum entries and Drupal articles, but I'm stuck.

In my hook_form() implementation, I've got:

$field_collection_item = entity_create('field_collection_item', array('field_name' => 'my_fc_field_name'));
// In a content type, use ('node', $node) instead
$field_collection_item->setHostEntity('taxonomy_term', $term);

// Not sure if those three lines are usefull
$field_node_example_values = field_get_items('taxonomy_term', $term, 'my_fc_field_name');
$field_node_example_ids = field_collection_field_item_to_ids($field_node_example_values);
$field_node_example_fc_items = field_collection_item_load_multiple($field_node_example_ids);

// Not sure if this line is correct
$form_state['field']['my_fc_field_name'] = $field_node_example_fc_items;

/* All examples below produce the same result : only one instance of the FC form appears, with no existing values and no buttons */

module_load_include('inc', 'field_collection', 'field_collection.pages');

// 1/
$form = field_collection_item_form($form, $form_state, $field_collection_item);

// OR

// 2/
$form['my_form_entry'] = array();
field_attach_form('field_collection_item', $field_collection_item, $form['my_form_entry'], $form_state);

// OR

// 3/
$output = drupal_get_form('field_collection_item_form', $field_collection_item);
$form['my_form_entry'] = $output;

So, my goal would be to get the same result as "out of the box" FC edit form, a nice fieldset with as many instances as exist, with Remove and Add buttons.

To be clear, I can see this type of form when I edit the taxonomy term, but I'd like to do it in a custom module.

I've look into the FC module, specifically the field_collection_field_attach_form and field_collection_field_widget_form functions, but I'm not sure how I could use them.

Some useful articles and forum entries:

http://www.cocomore.com/blog/field-collections-exposed
https://www.drupal.org/node/1842304
How to pre-populate multiple "field collection" fields in node form
https://stackoverflow.com/questions/13364905/need-an-example-on-attaching-a-field-collection-to-a-drupal-form-drupal-7
https://stackoverflow.com/questions/18447025/adding-drupal-field-collection-element-to-a-custom-form
https://www.drupal.org/node/1337804#comment-6326678


texts: Control number of autocomplete results in drupal?

texts: Is there any way to control number of results in an autocompleted field in drupal?.  Usually node reference autocomplete fields provide 10 results, i want to increase the count, is there any global configuration availabe or how can i alter the count?


texts: How can I let images uploaded via ckeditor show their full url in a json request via REST?

texts: I have textarea fields in my headless drupal 8 site. When I get the node via REST in json it does not give the domain name in the image urls that are uploaded via ckeditor. So the images are not shown when I display this field.


texts: How to exclude a custom 404 error page (not found) from a Popular Content block?

texts:
Is there a way to stop a custom 404 page from being added to the Popular Content block?

I set up a node for the custom 404 page. But every time a missing page gets redirected there, it increases the number of page hits of that node (of course). Which increases its ranking in Popular Content blocks also.

Is there some configuration setting to exclude it from Popular Content blocks, or place it in a different category?


texts: Charge user after status of order is changed with eCommerce

texts:
I am using the Drupal 7 eCommerce kickstart distribution.

I want to sell service (like cleaning, gardening...), and I want user to be able to create order, but I want to give them ability to do payment after service is done.

Is there any way to do this, to make user able to make payment after they create order.


texts:
So I know this might not necessarily be a "Drupal" issue, but because I am using Drupal and this issue only happens in my Drupal site, I'm wondering if it has something to do with the way Drupal handles URL's.

SO, I have an anchor on my home page like so:

There is a link in the main navigation that is on all pages to this anchor like so:

We Know Digital

So this works in all browsers, including Firefox, when I am ALREADY on the home page, however, if I am on one of the internal pages and then click this link, it takes me to the homepage, but does NOT go down to the anchor in Firefox. It does go down to the anchor in Chrome and Safari and other browsers, but for some reason it wont in Firefox, even in the latest version. The reason I believe this has something to do with the way Drupal handles URL's is that if I create a standalone plain vanilla HTML page outside of Drupal and replicate the same thing where I have 1 page that has the link and the anchor and then a separate page that has the link to the first page and the anchor, it works as expected in Firefox where it goes to the first page and then down to the anchor. It's only when I try to do this within Drupal, that it stops working. Anyone have any idea what might be going on here? I'm thinking it has something to do with the URL re-writing. ???


texts:
I am using a zen subtheme and my footer and site logo are displaying in the admin overlay. I would like to remove them.

I tried hiding them by doing the following in my theme css:

#overlay logo img {
    display: none;
    border: 1px solid red;
}

#overlay #footer-wrapper {
    display: none;
    border: 1px solid red;
}

The logo and footer are still displaying... but the styles are not being picked up...

Also, selecting or unselecting the "Use the administration theme when editing or creating content" settings makes no difference to the appearence.


texts:
I'm trying to use the feeds module to import structured data from a CSV file and map the values to node. I'm having an issue with a CSV field that contains multiple values.

e.g.
ingredients['peanut butter', 'jelly',]

Is there a good way accomplish this with feeds, or would I be better off writing my own custom mapping engine module? I'd prefer to find a way to get the Feeds module to work to avoid having to spend excess time on something that is already done.


texts:
I have a content type called Snippet. Snippet will have one image field and unlimited text fields.

I want to output fields in Views as:

image field (image.png)
text field (Text1)
text field (Text2)
text field (Text3)
text field (Text4)

The image field is always first, and the different text fields follow it. I want to put this into a slideshow format with fade transitions.

Right now, the image field keeps reproducing itself after every text field.

Do you have any idea? Do I need to use grouping?


texts: How to get back the text formats like filtered_html, full_html or php_code for wysiwyg

texts:
I accidentally removed the text formats like:

Full HTML
Filtered HTML
PHP Code

from admin > config > content authoring > text formats.

I want to get them back but couldn't find a way. I re-installed the third party editor (ckeditor) for wysiwyg and also reinstalled the wysiwyg module, but it didn't help.


texts:
I have been working on a custom field plugin with which the aim is to create a custom field to be used for content and will consist of a link field and a file field through which a thumb image is to be uploaded. I'm ok with the first part is i.e. the link field for which I have declared a uri data definition with a varchar storage schema and a url type for the form element. But I cannot (based on the available documentation) figure out the proper way to manage the file field. I have used a managed_field type as for the form element but cannot figure out what is the correct datatype and storage schema to use.

Edit: The documentation I have found deals with three parts,

The field class where the propertyDefinitions method is overridden and the properties are defined (ex. $properties['link'] = DataDefinition::create('uri')->setLabel(t('Video Link'));)
Also in the field class where the schema method is overridden and the storage properties are defined (ex. $columns['link'] = [ 'type' => 'varchar', 'length' => 255, ];)
the widget class where the formElement method is overridden to define the input form (ex. $element['link'] = [
        '#type' => 'url',
        '#title' => t('Link'),
        '#default_value' => isset($items[$delta]->link) ? $items[$delta]->link : null,
        '#empty_value' => '',
        '#placeholder' => t('Insert a url'),
    ];)

what should the equivalent parts for an image/file field property be defined?

any input would be appreciated, thanks


texts: How do I save a new field value for node without saving the node?

texts:
I am developing a Drupal 8 website and I added a new field to a custom content type called Download. This field is updated each time a file is downloaded from this content type. I use hook_file_access to find a node from which a file was downloaded. I then get current download count value by getting a field from a node. The value is incremented by 1 and the new value is stored in the field. I then save the node to store the value. Below is the code used for node (field change) saving:

$field_download_count = $entity->get('field_download_count')->get(0);
if ($field_download_count == null) {
    $download_count = 1;
} else {
    $download_count = $field_download_count->getValue()['value'];
    $download_count += 1;
}
$entity->set('field_download_count', $download_count);
$entity->setNewRevision(false);
$entity->save();

The problem is that with this code, updated date of the content changes and this is a problem for me as I use updated date in many view and data is not valid as per this code, updated date is changed with each file download from the node.

Is there a way to store the field value only on Drupal 8?

In Drupal 7, one could use field_attach_update but this function was removed in Drupal 8.

I tried to update the field value using Drupal update SQL function, but this is not a proper way and also didn't play well with a cache system.


texts: Can't get favicon/shortcut icon to show up

texts:
Despite trying multiple times various favicon location approaches:

at theme root
at files root
uploading the file through admin/appearance/settings
typing in a path of manually uploaded icon

always clearing cache afterwards, I cannot get my shortcut icon to show up.

I tried pasting into the browser's address bar the path of the ico file so to force an update, but I got a generic server error that there was no such file at this location. When I looked into the generated source code, I could not see neither my file nor the default drupal icon. So I'm completely lost.

I'm close to modifying the html.tpl.php by pasting the link tag manually or through drupal_add_html_head_link but I'm puzzled because it happened to me for the first time. Any clue what else I could double-check?


texts: HOOK_form_block_form_alter works on Block Layout Form but not on Block Form in Page Manager and Panels

texts:
My ultimate goal is to apply an extra set of style options to any block including the core blocks. So I created a custom module with this code in the .module file

function mymodule_form_block_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
    $form['mymodule_style'] = [
        'background' => [
            '#type' => 'details',
            '#title' => $this->t('Background'),
            '#open' => FALSE,
            'color' => [
                '#type' => 'select',
                '#options' => [
                    '' => $this->t('Default'),
                    'bg-orange' => $this->t('Orange'),
                    'bg-grey' => $this->t('Grey'),
                ],
            ],
        ],
    ];
}

And it appears that it works in /structure/blocklayout but I use page manager and panels for my block placement and those options don't appear there. Is there another hook related specifically to panel plugin forms? Also if there is, where in the code are these hooks defined, so I can easily discover this for any module in the future?


texts:
Could somebody give me an example of how to use token_replace()?
I'm trying to write a custom PHP rule for the Rules module that will rewrite few fields of a new saved content, using the values from tokens.


texts:
I really want to like the configuration management system in Drupal. Over time, I've learned to tamp down my expectations in how it can be used to develop against a production config.
On production, I've set up a display view_mode, which is complex undertaking using the admin interface for over 30 custom fields. Once I get one done, I want to "save as" into another display for this content type. In D7, in Display Suite, I had the option to clone an existing display, but cannot find that for the life of me.

So I create the new display for this content type so that it is instantiated in the db's config table. I then use drush cex to get them all, open up the source config file, copy the dependencies from the source config, paste only the analog dependencies in the newly generated display config file from the db. I take care to not overwrite the uuid values because they must map to the existing entities. Using either the Configuration Management module, or drush cim I get the SQL error that it will not overwrite/update the existing config.

  Unexpected error during import with operation update for
  core.entity_view_display.node.doctor.internship: SQLSTATE[23000]:
  Integrity constraint violation: 1062 Duplicate entry
  'core.entity_view_display.node.doctor.internship_directory_photo' for
  key 'PRIMARY': UPDATE {config} SET ...

This ought to be doable, since all the dependencies are there, just wanting to save aggravation and time for all the variations I need to create.

More info on experiments. Say, my target config is "foo" and my file is foo.yml for this exercise. Comparing my source and target, I can see that a wholesale copy/past of the dependencies is too much. For one, there is an id key that must have the value of "foo" to match this new target config. There are others. Since there is a "foo" config in the config table, I deleted that row. Attempting drush cim the error is no longer a duplicate, but similar to this:

  Unexpected error during import with operation create for foo; entity
  with foo already exists.

Hmm, I have not assigned a node to this display yet. Is it complaining about the config entity, or another, perhaps node, entity?


texts: How to ban a commentator's IP address with Rules?

texts:
When spammy comments appear on my website, I delete them and manually add the commentator's IP address to the banned list. However, it should be easier to Flag the comment with a new comment Flag Spam and then perform the previous actions automatically with a Rule.

The problem is that the Rules action Block an IP address cannot select the token [flagged-comment:hostname], which is perfectly accessible in other Rules actions. The reason for this problem is probably that the action Block an IP address only accepts values of the type IP address, as one can verify in the original patch for this feature. However, [flagged-comment:hostname] is not of this type (I think it is just a text). Moreover, storing the hostname in a variable and converting it into an IP address does not work either, because the latter is impossible.

Is there a fix for this?


texts: Drupal 7 Trying to create a "Today in History" view

texts:
I'm sure there's an easy way to do the following but I've not come up with a safe Drupal way to do so:

My current front page has a view which generates a list of the most recent three articles on my site using the date stored in  field_published attached to each article. The SQL which the view generates looks like this:

SELECT field_data_field_published.field_published_value AS field_data_field_published_field_published_value, node.nid AS nid FROM node node LEFT JOIN field_data_field_published field_data_field_published ON node.nid = field_data_field_published.entity_id AND (field_data_field_published.entity_type = 'node' AND field_data_field_published.deleted = '0') WHERE (( (node.status = '1') )) ORDER BY field_data_field_published_field_published_value DESC LIMIT 3 OFFSET 0;

( You can see what this looks like live on my website )

Running the query on mysql CLI generates this:

+--------------------------------------------------+-----+
| field_data_field_published_field_published_value | nid |
+--------------------------------------------------+-----+
| 2017-01-23 00:00:00                              | 427 |
| 2017-01-01 00:00:00                              | 426 |
| 2016-08-07 00:00:00                              | 424 |
+--------------------------------------------------+-----+

I want to now create a similar view that searches only the month and day field of every article in the DB, matches the month and day against 'today', and generates a list of article nid. The SQL for this is:

SELECT field_data_field_published.field_published_value AS field_data_field_published_field_published_value, node.nid AS nid FROM node node LEFT JOIN field_data_field_published field_data_field_published ON node.nid = field_data_field_published.entity_id AND field_data_field_published.entity_type = 'node' WHERE (( (field_data_field_published.field_published_value LIKE (select date_format(curdate(),'____-%m-%d%'))) )) AND (( (node.status = '1') ))
ORDER BY field_data_field_published_field_published_value DESC LIMIT 3 OFFSET 0;

This correctly generates a list of article nid on the CLI:

+--------------------------------------------------+-----+
| field_data_field_published_field_published_value | nid |
+--------------------------------------------------+-----+
| 2015-05-24 00:00:00                              | 369 |
| 1999-05-24 00:00:00                              | 222 |
| 1997-05-24 00:00:00                              | 150 |
+--------------------------------------------------+-----+

My question is, how do I get my functional SQL statement into a view?

I have tried using Views Contextual Filters and Granularity, but that does not allow me to omit the year when filtering dates.

I have tried to use hook views_pre_execute in a module but it barfs on my query: Something like

<?php
// TMG 3-21-09
// call to hook_views_pre_execute to override the query for the groups browser
function views_views_pre_execute(&$view) {
   if($view->name=="future_front_page2") {
       $kp_tih = date('____-m-d%');
       $view->build_info['query']="SELECT field_data_field_published.field_pub
lished_value AS field_data_field_published_field_published_value, node.nid AS ni
d FROM node node LEFT JOIN field_data_field_published field_data_field_published
 ON node.nid = field_data_field_published.entity_id AND field_data_field_publish
ed.entity_type = 'node' WHERE (( (field_data_field_published.field_published_val
ue LIKE (select date_format(curdate(),'____-%m-%d%'))) )) AND (( (node.status =
'1') )) ORDER BY field_data_field_published_field_published_value DESC LIMIT 3 O
FFSET 0";
       $query = db_select('node','n')->addTag('node_access');
       drupal_set_message(t($query));

Any suggestions?

Thanks in advance for any advice.


texts: more fields on a content type or more content types

texts:
I know this is a situational/subjective question..... but I am trying to figure out a site architecture for a drupal site.

I have multiple products with different attributes/properties. I could either make one content type called 'products' with multiple fields for all possible attributes ..... or I could could make multiple content types; one for each type of product.

I am just looking for a 'best practice' kind of answer.

should I make one content type with more fields (that may go unused more often)

....

or should I make more content types.

Thanks in advance.


texts: Drupal multisite configuration with a single database and redirection based on IP

texts:
I need to implement multi site configuration in Drupal 7. I have a Drupal code base called example.com and two subdomains sub1.example.com and sub2.example.com in sites/ folder. I am using a shared database also. My requirement is to to redirect a user to sub1.example.com if the user enters the url http://example.com from country1. When any other user hits the same url http://example.com from country2 then he must be redirected to sub2.example.com. The user must be unaware of the country specific domain redirection.

I am using drupal 7.7. I installed ip2locale module for redirecting the users based on their IP and a domain access module also is installed.

  Is the domain access module really needed for meeting my requirement ?

If I have to use domain access module

  do I need to set up virtual host separately for each sub domain when
  domain access module is used? Is ip2locale module alone sufficient for
  redirection based on IP?


texts: How to disable front page view programmatically?

texts:
I have another view that uses the same path as the front page view which is "/node" and I will like to disable the front page view programmatically.

How can I do that from a hook_install?


texts: how to put arguments into contextual filters

texts:
In this post http://drupal.org/node/228959 says that i need to add an code to the argument of view2,

I add a contextual filter in views 3, but where is the spot to place the following code?

if (arg(0) == 'user' && is_numeric(arg(1))) {
    return array(arg(1));
}


texts:
This is pretty embarrassing but I gotta start somewhere, right? This concerns about installing Apache Solr.

I've seen the instructions when trying to install Apache Solr and each one starts off with installing Java. I'm confused since I'm using Bluehost for webhosting (http://drupal.org/hosting). Does that mean I need to install Java on my server? There's also the thing about the terminal but I've never seen the terminal in my hosting's Cpanel. Help.

Edit: By terminal does that mean SSH? Because I can have that enabled in cPanel. It would be nice if there were a simple tutorial for cPanel's users like me. :-)


texts: Drupal 7, passing URL arguments page not found

texts:
Good evening. Please help me.

I built my website on my home pc using Wamp as webserver.  On one page I pass arguments to backend.php via URL.

Like this

echo "<button >nbsp$row[1]</button>";

The code is working fine.

Now I uploaded the site to my godaddy hosting and can’t send the argument in the same manner.  I gives me 404.
The requested page "/backend.php?g=http://bc.luckyfaucets.com/" could not be found.

The code is exactly the same as on my home server,  .htaccess is the same and they both have clean URL enabled.
Can someone tell me the cause of this ?

This is the backend.php file.

<?php
define('DRUPAL_ROOT', getcwd());
require_once
DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
variable_set('ref', $_GET['g']);
$g = $_GET['g'];

$con=mysqli_connect($db_host,$db_user,$db_pwd,$database);

// Get infos siteid sitecyle from _sites_
$result = mysqli_query($con, "SELECT `siteid`, `sitecycle` FROM `_sites_` WHERE     `siteurl` = '$g'");

while($row = mysqli_fetch_row($result)) {
$siteid = $row[0];
$sitecycle = $row[1];
// Count time + sitecycle
$next = (time() + ($row[1]*60)+15);
}
// Update _counters_
$result = mysqli_query($con, "SELECT `siteid`, `uid` FROM _counters_ WHERE `uid` ='$user->uid' AND `siteid` ='$siteid'");
if( mysqli_num_rows($result) > 0) {
    mysqli_query($con, "UPDATE _counters_ SET `cycleend` = '$next' WHERE `uid` = '$user->uid' AND `siteid` = '$siteid'");
    }
else
{
    mysqli_query($con, "INSERT INTO _counters_ (uid, siteid, cycleend) VALUES ('$user->uid', '$siteid', '$next')");
 }
 drupal_goto('page');
?>

I would like to know what/why the same code does work with Wamp but not on my hosting. Is this maybe cause by some setting at godaddy?

Thanks for the help


texts:
I have a node activity with fields referencing the node location and a node sport_type. As in, for each activity I need to add a location and a sport type.

On the other hand I also have a node admin with references to location and sport_type. As in, I can create an admin for each sport_type and each location.

How can I create a view which results in the admin when an activity nid is given?

In SQL I would write something like:

SELECT  admin.name
FROM    admin
JOIN    activity ON activity.location_id = admin.location_id
        AND activity.sport_type_id = admin.sport_type_id
WHERE   activity.nid = :nid

I try to create a similar query using the ui of views, where the activity_id would be passed in through the url path. I don't know how to implement the join though... Any tips? (Using Drupal 7)


texts:
I have created a website for yacht charter http://cozmoyachts.com

I have created one booking form for yacht booking using webform module and used that form on all yachts pages.
Like 45 feet yacht, 55 feet yacht and so on...

In that form there is a select list to select a yacht.

I want to change the default value of that select list according to the URL of page.

So if the visitor is on 33 feet yacht page the default value in select of booking form should be 33 Feet Yacht.

Hope I am able explain my question properly.


texts: Trying to render a custom date format with Twig

texts:
I'm in the process of porting one of my contrib themes to Drupal 8. For custom date formats on nodes, I have something like this in a node_preprocess function in the theme's template.php file in the Drupal 7 version:

$vars['thedate'] = format_date($node->created, "custom", "j");
$vars['themonth'] = format_date($node->created, "custom", "M");
$vars['theyear'] = format_date($node->created, "custom", "Y");

I render it with the following code.

  <?php print $thedate; ?> / <?php print $themonth; ?> / <?php print $theyear; ?>

In my Drupal 8 port, I've tried a similar approach in the theme's .theme file and then try to render them in node.html.twig as {{{ thedate }} / {{ themonth }} / {{ theyear }}}, but I'm getting a nasty error.

  Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("The timestamp must be numeric.") in themes/mytheme/templates/page.html.twig
          at line 210. in Twig_Template->displayWithErrorHandling()
          (line 279 of /site/core/vendor/twig/twig/lib/Twig/Template.php).

I looked to Twig date formats, and it seems you should simply attach a variable, such as {{ display_submitted |date("m/d/Y") }}. I tried that without a preprocess function but what outputs is 12/31/1969, which is not the date the node was created so I'm a bit lost here.


texts: Product color from select list in Commerce Kickstart 2

texts:
I thought it would be simple, but either I'm stupid or the commerce kickstart 2 doesn't have such functionality.

I've created a t-shirt product variation and I want to give my customers the possibility of choosing their favorite color from a color picker or from a select list. The color doesn’t affect the price.

As I see the only option for doing this in kickstart commerce is by creating each variation per color.
Is there any other way to accomplish this? I just want to create t-shirt and let people choose their color.

Please help me I'm getting very frustrated.


texts: Unique file system for multiple domains in Domain Access

texts:
I have created five domains using domain access module like

test1.com
test2.com
test3.com
etc,

Now i want each users from different domains have to use unique file system in order to upload media.
From that i don't what users from other domains can access remaining domain's file system.

for example test1.com users can access only their own file system called test1.

Is there any way to do this in Domain Access Module? or any other module & Coding is needed?


texts: Display certain field values of submissions from multiple webforms in one view

texts:
I have two separate webforms, and I want to be able to display all submissions from both webforms that have the same value of a specific field. I also want different fields to be displayed based on what form they're coming from.

For example, both webforms have a field called area.
I would like to display the submissions of both these webforms if they both have area set to the same value. Amongst these submissions, if they're from form 1, I want to display the values for field1,field2,and field3 in the view. If they're from form2, I want to display the values for field4,field5, and field6 in the view.

Is there a way to accomplish this in a view?


texts: How to display the user email on account pages?

texts:
On the user account page all feilds are displayed except for the email. I have tried to modify the user-profile.tpl, and added

print $user->mail

but it displays the logged in user and not the account being displayed. Not a big problem since the end users usually only see their own account bit frustrating for admins. I also tried

print render($user_profile['mail']);

but that displays nothing.


texts:
I'm trying to add a Moderation Dashboard tab to the user page like the Moderation Dashboard module, but I can't use Panels. Is it possible to create a layout on a route using layout builder?

I've created the route in msk_module/my_module.routing.yml with

my_module.moderation_dashboard:
  path: '/user/{user}/dashboard'
  defaults:
    _title: 'Moderation Dashboard'
    _controller: '\Drupal\my_module\Controller\MyModuleDashboardController::index'
  requirements:
    _user_is_logged_in: 'TRUE'

And the links task in msk_module/my_module.links.task.yml with

my_module.moderation_dashboard:
  route_name: my_module.moderation_dashboard
  base_route: entity.user.canonical
  title: 'Moderation Dashboard'
  weight: 30

And started the controller in msk_module/src/Controller/MyModuleDashboardController.php with

<?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
 * Controller for moderation dashboard.
 */
class MyModuleDashboardController extends ControllerBase {

  /**
   * Display the markup.
   *
   * @return array
   *   Return markup array.
   */
  public function index() {
    return [
      '#type' => 'markup',
      '#markup' => $this->t('Hello, World!'),
    ];
  }

}

So the tab is where I want it. The contents for the tab are the block views displays from the views from  Moderation Dashboard. I suppose I can use hook_theme() and a template and some small amount of CSS. Just wondering if layout builder can do the same thing as the panel in page manager can do?


texts: Feed import save empty value in multilingual site

texts:
I have a multilingual site and I am using the feed module to import content. My site has two languages:

English and Arabic.

When my excel files have English content, it imports properly.

But if excel file having Arabic content, it imports and shows in view page but in edit page it not displaying.


texts: custom display of taxonomy list in views

texts:
I'm using a "Content:All Taxonomy Fields" field in a View.  Works great, but-

Can I change the display of taxonomy field lists without custom code?  The vocabulary has an image field I've added...I'd love to show the image instead of the name when listed.

Thanks!


texts: Setting up an exposed filter to only filter conditionally

texts:
I am trying to build a D7 view, and I have the view correctly only showing results using a contextual filter, but I am trying to build one more filter (an exposed one), to drill down even more.

I have a list of students, each students assigned to different districts. A user is assigned to one (or multiple) districts, but should never be assigned to all (but could be). The contextual filter is checking the assigned_user field of the district using the logged in user, and that works.

I have the student and district relationship setup, and it pulls all data from both entities correctly.

Now I am trying to build an exposed filter so that the user can select which district they want to filter by, but ONLY list the districts they are assigned to. When using the 'expose filter' option on the district name, if I use 'Single Filter' it makes it a textbox instead of a select box, and if I use 'group filter', it makes a select box, but I have to manually put in each district.

I am trying to #1, get the exposed filter to be a select list,
and #2 ONLY the districts the user has access to (via the assigned_user contextual filter). The views UI doesn't appear to have a way to do this, so is it possible for me to write a hook to create the filter myself?


texts: Update script fails due to Service capacity

texts:
I am trying to update the core of my Drupal site. I neglected updates for some time and the update script had 19 updates pending. Apperently the update script tries to do all of this in one go, and fails miserably. I get an error message like this:

StatusText: Service Unavailable ResponseText: 503 Service Unavailable Service
Unavailable The server is temporarily unable to service your request due to maintenance
downtime or capacity problems. Please try again later.

and this one:

  An AJAX HTTP error occurred. HTTP Result Code: 503 Debugging
  information follows. Path: h t t p
  ://mysite.com/update.php?op=selection&token=7R0M7yvUZR09UsRDFf9FUAYhV9Ui82efUzsZPh61JZU&id=152&op=do
  StatusText: Service Unavailable ResponseText: 503 Service Unavailable
  Service Unavailable The server is temporarily unable to service your
  request due to maintenance downtime or capacity problems. Please try
  again later.

I have the following questions:

Has anyone seen this one before? If so how do I solve it?
If not, can I run the other 18 pending updates somehow?
If not, how harmfull is it if I don't run update.php?


texts: How to set up a child theme using pattern lab?

texts: I have multisite architecture in drupal 8. and I am using pattern lab in my base theme but now I want to access some component from parent theme to child theme. What would be the best way to create child theme using pattern lab? Thanks in advance.


texts: How to create product bundle or similar to that?

texts:
I have a plan to create a e-commerece website for Computer Assembling.
I have exp in Prestatshop and few other CMS (e-commerce) framework.
In that i found Drupal 7 is having the best one like durpalecommerece. So I selected Drupal 7 as CMS framework.
I download few modules ubercart and tried e-commerce module also.

But its not meeting my requirements. My requirement is

Homepage - User can see All default PC set (Monitor, CPU, Keyboard and Mouse) with price.
Select PC, Next page description will display.
Defualt Product piece is 1, but the user can increase more.
Based on the increase Rate will be changed.

Above steps are working fine. Below steps are not working.

Homepage - If user doesn't happy with default PC set, User can build there own PC
Select "Build own PC".
List of Monitor companies and inches will display.
User selects one monitor and click,
It will redirect to CPU Parts.
User will select Mother board, ram, hardisk ... one by one
On click "NEXT" redirect to shopping cart....

How to achive Product bundle here to get calculate amount in cart


texts:
So, I'm relatively new to Drupal, and I'd like to make a Drupal site with a front page with a grid of links to other commonly used pages on the site. This site is intended as a sort of community page for a small town, so it would be links like Government, News, Business Directory, History, Forum, etc.

Some of these pages are basic pages on my Drupal site, some are external links, and some are links to views or modules, like the aggregator module. I'd like all of the links to be sortable and generally have the same markup. I'd also like these links to be gathered automatically, i.e. via the 'Promote to Front Page' option or something like that. I ABSOLUTELY DO NOT want to hardcode this to a basic page.

So far my solution has been to create a view with a list of title fields from pages promoted to the front page, and a special content type I named 'Link' which are actually just redirects to external urls. The problem now is that I don't know how to include special pages, like aggregator or view.

Any ideas? Is there a better way to do this? Have I missed something?


texts: Aggregated javascript contains binary data, breaks site

texts:
Today I noticed a site's javascript was broken. One of the aggregated javascript files contained a bunch a binary data that (obviously) caused a syntax error;

‹EAk1…ÿŠæ”°!«Ð–¢Á¶]¤µ'³³6â&K2ºÑßÞ,J{3ï½éWgÈzÇAn¤ç#„^)QVãR³ù¬X³ìzåÜaÛ{B¡¶H[#ùóÓ>
Ë

After deactivating the js aggregation the site works fine, and none of the javascript looks off.


texts:
i spent 2 days looking for a solution and I'm still looking for help.

i would like to create a chart using highcharts.
i need the syntax of the array to render.

i tested this solution and it works but i can't understand the syntax of the Options Array.

https://www.webwash.net/drupal/tutorials/intro-visualization-api-part-2-highcharts-and-code#comment-3056

I need somebody who can explain the Syntax because .

Regards


texts: How Not To Update Existing Taxonomy Terms At Migration

texts:
I am using migrate and migrate_d2d to migrate taxonomy terms from a d7 site to another d7 site.How can I specify in my migration that nothing be done if the term already exist in the target?
So far, in "prepare" function, I am querying the target to find out if the term already exist, but I am not sure if this is the right way to go about it or where to go from here.

function prepare($entity, stdClass $row) {
  $term_name = $entity->name;
  $query_checking_if_term_exist = db_select('taxonomy_term_data', 'ttd')
    ->condition('ttd.name', $term_name)
    /* TODO: fetch vid from taxonomy_vocabulary table instead of hardcoding it */
    ->condition('ttd.vid', '2')
    ->fields('ttd', array('name'));
  $term_exists = $query_checking_if_term_exist->execute()->fetchAll();
  if(isset($term_exists)) {
    //TODO
  }
}


texts: How to exclude certain variable from the Feature code?

texts:
In my Feature I wanted to add the multilingual path_breadcrumbs_home_link_title for en and de, but when generating the feature by including the realm_variables there is the site_name and site_slogan in the en array included too.

The site_name is a mandatory field, so I can not just leave it empty.

The generate file looks like this:

<?php

/**
 * Implements hook_variable_realm_default_variables().
 */
function foo_variable_realm_default_variables() {
  $realm_variables = array();
  $realm_variables['language']['de'] = array(
    'path_breadcrumbs_delimiter' => '»',
    'path_breadcrumbs_home_link_title' => 'Startseite',
  );
  $realm_variables['language']['en'] = array(
    'path_breadcrumbs_delimiter' => '»',
    'path_breadcrumbs_home_link_title' => 'Home',
    'site_name' => 'Demo Site',
    'site_slogan' => '',
  );
  return $realm_variables;
}

The site name would overwrite all the site names of any already deployed Drupal site.

I don't understand why it doesn't appear in the de array even while site name is set there too.

How can I get rid of this?

Any workarounds?


texts: Is there a way to create one panel page for multiple i.e 7,8 view displays

texts:
A view has 7-8 displays … all of them are pages. I want them to layout (i.e the page) when any of the 7 pages is visited the view content should come up in the left pane of a panel i.e col-sm-8(bootstrap class) while the right col-sm-4 should be reserved for sidebar purpose.

There are several ways to do it … what would you suggest ? Should I create a panel page for each of the view display or there is a way to create one panel page for all ? i.e targeting there URL paths

/news
/most-read
... etc


texts:
I've just setup Youtube Uploader module version 7.1-2.1.
Everything works fine when I add video to the node manually.

What I want is to put video into youtube_uploader field from my PHP code.
For some reason get an error.

The part of the code is:

 // Create a node for song:
$language = LANGUAGE_NONE;
$song = new stdClass();
$song->type = 'song';
node_object_prepare($song);
$song->title = $node->title . ' (' . $performer->name . ')';
$song->language = $language;
$song->uid = $uid;
...
$song->field_video_youtube[$language][0] = (array)$videoFile;
$song->field_video_youtube_video_title[$language][0] = $node->title . ' (' . $performer->name . ')';
node_save($song);

Youtube uploader field - field_video_youtube
field_video_youtube_video_title is extra field added as I get errors from PostgreSQL.

Messages from Postgres:

    2016-01-09 20:14:29 MSK ERROR:  null value in column "field_video_youtube_video_title" violates not-null constraint
    2016-01-09 20:14:29 MSK DETAIL:  Failing row contains (node, song, 0, 92084, 92077, und, 0, 43192, null, null, 1).
    2016-01-09 20:14:29 MSK STATEMENT:  INSERT INTO field_data_field_video_youtube (entity_type, entity_id, revision_id, bundle, delta, language, field_video_youtube_fid, field_video_youtube_thumb_fid, field_video_youtube_video_title, field_video_youtube_display) VALUES ('node', '92084', '92077', 'song', '0', 'und', '43192', NULL, NULL, '1')

What's wrong with the code?

Thanks in advance for your help!


texts: Will Drupal or PHP use APC if its installed on the server?

texts:
So I have AuthCache installed with XCache but I am not getting any noticeable speed. Im on D6 so its not possible to use APC?  I mean if APC is installed on the server , will Drupal use it even if I don't install the APC module?

Thanks!


texts: How can I build the results of a view in code then send them to the view?

texts:
Say I have a content type, nodes, that I want to serve through a view.

The problem is, the results are based on a series of complex requirements and conditions that aren't easily controlled through the Views UI. That is, I would like to determine which nodes to output in the view in code - is there a hook I can use to effectively build up the results, which are then fed through to the 'dumb' view?

In this way, I can do all my complex querying and calculations in code, then simply provide an array or similar of objects that the view will treat as its results, and simply spit them out?

EDIT: This doesn't necessarily have to be mediated through views, it's just I can't build the query I want in views easily because it's got a lot of moving parts.


texts: Does drush have built-in variables or macros?

texts:
Does drush have built-in or predefined variables or macros?

An example would be like the base directory of the Drupal installation, database name, passwords etc? Something like the values displayed in drush status


texts: How do I add an extra field to the commerce product entity and have it show on the product display?

texts:
I am trying to add an extra field to commerce product and have it show on the corresponding product display node. So far I created the extra field and declared a theme function as shown below:

/*
 * Implements hook_field_extra_fields()
 */
function example_field_extra_fields() {
  $extra = array();

  foreach (commerce_product_types() as $type => $product_type) {
    $extra['commerce_product'][$type] = array(
      'display' => array(
        'bulk_savings' => array(
          'label' => t('Bulk Savings'),
          'description' => t('Bulk savings'),
          'theme' => 'example_bulk_savings',
          'weight' => 0,
        ),
      )
    );
  }
  return $extra;
}

/**
  * Implements hook_theme().
  */
function example_theme($existing, $type, $theme, $path) {
  return array(
    'example_bulk_savings' => array(
      'variables' => array('bulk_savings' => NULL, 'label' => NULL, 'product' => NULL),
    ),
  );
}

/*
 * Bulk savings theme function.
 */
function theme_example_bulk_savings($variables) {
  $output = check_plain($variables['bulk_savings']);
  return $output;
}

The last step would be declaring the contents of the field and attaching it the commerce product entity. I tried using hook_entity_view(), but only the node object is available on the product display node. Any help would be much appreciated.

Thank you,

Paul


texts:
I am trying to make secondary menu grow on mouse hover. just like this site

we can see on the bottom of the page. menu block can grow bigger and show more menu.

any idea what technique used to make something like that. or maybe a module or maybe jQuery. right now i'm still googling but still got no clues.
Please let me know some idea about this.

Regards

mbahlol
pardon for my english


texts: how to print login_days with user_stats module?

texts:
<?php print format_date(user_stats_get_stats('login_days', $node->uid), 'custom', 'j'); ?>

Returns "1" always, how to use user_stats - login_days correctly?


texts: How to display "NEW" label in comments list

texts:
How do I display the "(new)" label in comments listing page.
What is the logic of displaying the "(new)" label. How does it work?


texts: Compute price based on order item fields

texts:
Is it possible to get the order items fields in a price resolver using Drupal 8 and Commerce 2.x?

Indeed, the resolve method in a price resolver only allow to access the purchased entity, quantity and context.

public function resolve(PurchasableEntityInterface $entity, $quantity, Context $contex) {}

I would like to:

Define some custom fields in an "Order Item Type" (In my case the fields are dates.)
Expose those fields in the add-to-cart form
Define product variation and product that uses that custom order item type, to have my custom add-to-cart form
Compute the purchased product price (in a custom Price resolver) according to field values provided in the add-to-cart form

I could use product attributes to achieve that, but unfortunately the values entered in the order item fields are not finite.

Notes

This looks similar to  https://www.drupal.org/project/commerce/issues/2836221, but I additionally need the entered field values to compute the final price
The answer in Update commerce price field with another custom field in Drupal 8 does not apply because I cannot define a finite set of values and create variations

How do I implement this in Commerce 2.x? Did I misunderstand something?

thanks in advance


texts:
Background: This is not the first question asked around here. I thought I found a solution but nothing worked in the end.

I have 2 content type: Parent and Child

Child possess 2 Entity Reference(ER) fields, Section and Parent(ER)

Section is linked to a Parent node, Parent(ER) is linked to another Child node, allowing for 3 level of Hierarchy, level 1 being a Parent node, level 2 being a Child node with a Section, level 3 being a Child node with a Section and a Parent(ER). I have created a Child node name NONE and use it as default for Parent(ER) to easily distinguish between level 2 (with no Parent(ER)) and level 3 (with a Parent(ER)) nodes.

I'm currently trying to build the menu for Child pages using multiple views providing data. Currently, I have the Parent(ER) section of said menu down, as it's pretty easy to build. The problem comes when I try to create the Siblings. Here is the requirement for this view:

I need to list all level 2 Child nodes, so the ones with a Section but no Parent(ER) (already dealt with using a conditional filter on Parent(ER) and checking for all pages with the NONE nid.)
I need to remove the currently displayed Child node as it's already present elsewhere
I need to print ONLY Child with the same Section as the current node

I can't find the contextual filter/relationship combination to achieve my goal.

How can I achieve this?


texts:
My code was working perfectly, but at some point my hook_menu page arguments stopped getting passed.

I am using versioning and can revert back to the previous code, but the page arguments are still broken.

Is there some change that could be causing page arguments to not get passed?

Thanks a million!

Disclaimer:  Sorry, I am not a Drupal developer, so the code is an attempt at injecting plain php into a site.

Inventory.module

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

  $items['admin/commerce/inventory'] = array(
    'title' => 'Inventory',
    'description' => 'View inventory reports for your store.',
    'access arguments' => array('access commerce reports'), // Inherited by children.
    'page callback' => 'inventory_reports_dashboard',
    'page arguments' => array( '10', 'DESC', 'false', 'admin@sltwtr.com', 'false'),     // page_arguments = threshold amount,  sort direction, hide zero inventory, email report to, save_to_email bool, download_csv
    'file' => 'inventory.dashboard.inc',
    'weight' => 0,
  );

  $items['admin/commerce/inventory-download-csv'] = array(
    'page callback' => 'inventory_download_csv',
    'access arguments' => array('access commerce reports'),
    'file' => 'inventory.dashboard.inc',
    //'type' => MENU_CALLBACK,
  );

  return $items;
}

Inventory.dashboard.inc

/**
 * Renders the inventory reports.
 */
function inventory_reports_dashboard( $threshold='10', $sort_direction='DESC', $hide_zero_inventory='false', $email='admin@sltwtr.com', $save_to_email = 'false') {
  drupal_add_js(drupal_get_path('module', 'commerce_reports') . '/theme/js/dashboard.js', 'file');
  drupal_add_css(drupal_get_path('module', 'commerce_reports') . '/theme/css/commerce_reports_dashboard.css');

  // on first load we want to grab all of the default values
  // after first load, we want updated values to pass through
  //$threshold = 18;
  $render = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . "/sites/all/modules/inventory/inventory.php?threshold=$threshold&sort_direction=$sort_direction&hide_zero_inventory=$hide_zero_inventory&email=$email&save_to_email=$save_to_email");

  return $render;
}

function inventory_download_csv(){
  $file = './inventory.csv';
  $filename = 'inventory.csv';
  //drupal_set_header('Content-Type: text/csv');
  //drupal_set_header('Content-Disposition: attachment; filename=' . $filename);
  drupal_add_http_header('Content-Type: text/csv');
  drupal_add_http_header('Content-Disposition: attachment; filename=' . $filename);
  if($file) {
    //file_transfer($file, array('Content-disposition', 'attachment; filename='.$filename));
    $csv_contents = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . "/sites/all/modules/inventory/inventory.csv");
  }
  else {
    return drupal_access_denied();
  }
  $fp = fopen('php://output', 'w');
  //$csv_text = array2csv($db_result);
  fputs($fp, $csv_contents);
  fclose($fp);
  exit();

}

Inventory.php

<?php

define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']);

require_once DRUPAL_ROOT . '/sites/all/modules/myfunctionlib/myfunctionlib.module';
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

//require_once DRUPAL_ROOT . '/includes/common.inc';
//require_once DRUPAL_ROOT . '/includes/module.inc';
//require_once DRUPAL_ROOT . '/includes/unicode.inc';
//require_once DRUPAL_ROOT . '/includes/file.inc';

//drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
clean_dump($_GET);

When I change the url:

mysite.gotpantheon.com/admin/commerce/inventory/12/DESC/false/admin@sltwtr.com

The get parameters no longer reflect changes

array(6) {
  ["threshold"]=>
  string(2) "10"
  ["sort_direction"]=>
  string(4) "DESC"
  ["hide_zero_inventory"]=>
  string(5) "false"
  ["email"]=>
  string(16) "admin@sltwtr.com"
  ["save_to_email"]=>
  string(5) "false"
  ["q"]=>
  string(0) ""
}


texts:
I have a custom logo and I have tried to get his path in this way theme_get_setting('logo_path'), but no expected result.

I am using the code in a custom block, in input PHP.


texts:
I have been trying to created a content type programmatically in Drupal 7. I notice that I should use the hook_node_info to generate the content type with the title and to add the body I should use the  node_add_body_field. I have been follow the examples modules ￼

So this is what I got as my code ...
non_recruiter.module

<?php

/**
 * Implements hook_node_info().
 */
function non_recruiter_node_info() {
  // We define the node type as an associative array.
  return array(
      'job_template_2' => array(
          'name' => t('Job Template 2'),
          'base' => 'job_template_2',
          'description' => t('A content type for posting your jobs.'),
          'title_label' => t('Job Template 2'),
          'locked' => TRUE,
      ),
  );
}

/**
 * Implements hook_node_type_insert().
 */
function non_recruiter_node_type_insert($content_type) {
  if ($content_type->type == 'job_template_2') {
      $body_instance = node_add_body_field($content_type, t('Job Description'));
        $body_instance['display']['non_recruiter_list'] = array(
        'label' => 'hidden',
        'type' => 'text_summary_or_trimmed',
    );

    // Save our changes to the body field instance.
    field_update_instance($body_instance);

    // Create all the fields we are adding to our content type.
    foreach (_non_recruiter_installed_fields() as $field) {
      field_create_field($field);
    }

    // Create all the instances for our fields.
    foreach (_non_recruiter_installed_instances() as $instance) {
      $instance['entity_type'] = 'node';
      $instance['bundle'] = 'non_recruiter';
      field_create_instance($instance);
    }
  }
}

/**
 * Implements hook_form().
 */
function non_recruiter_form($node, $form_state) {
  return node_content_form($node, $form_state);
}

function _non_recruiter_installed_fields() {
  return array(
      'non_recruiter_quantity' => array(
          'field_name'  => 'node_example_quantity',
          'cardinality' => 1,
          'type'        => 'text',
      ),
  );
}

function _non_recruiter_installed_instances() {
  return array(
      'non_recruiter_quantity' => array(
          'field_name'  => 'non_recruiter_quantity',
          'label' => t('Quantity required'),
          'type'        => 'text',
          'widget'      => array(
              'type'    => 'text_textfield',
          ),
          'display' => array(
              'non_recruiter_list' => array(
                  'label' => 'hidden',
                  'type' => 'hidden',
              ),
          ),
      ),
  );
}

So I took what they did and modify the code base on what I want.

My Goal is to have a content type that have the following fields...

Job Title (title)
Job Description (body)
Quantity (text)

But I'm doing something wrong because the fields are empty. If I try to add new content using this content type this is what I got ...

An empty content type, without any fields.

Here is some extra information of how my Manage Fields & Display looks like..
Manage Fields

Manage Display

So, can anyone tell me why my fields are not showing up in my content type ?


texts: How to debug no moderation_state on revision

texts:
I have a custom entity (not written by me) that I need to debug.  It's currently crashing when editing the Entity because there is no moderation_state on the default revision.  I'm new with both: revisions and content_moderation.  Is there a place in core where I should be looking to find example content entities, or does anyone know a good way to debug this?

Currently, the crash happens in ModerationInformation::isDefaultRevisionPublished.  There are 5 states available in the entity that's stumping me, so I'm not sure why the moderation_state isn't being brought back on the entity.

Thanks.


texts: Different roles create different amounts of a specific content type

texts:
I'm building a job directory where users are allowed to register (selecting a membership type) and create Companies and Jobs.

A membership can be Simple, Business or Premium. The membership type is treated in the similar way as a user role. See the list of roles:

My goal is:

if the user selects Simple membership (Authenticated user), he / she is going to be able
to create only 1 Company and 1 Job;
if the user selects Business membership (Business user), he / she is going to be able
to create 2 Companies and 3 Jobs.

How can I do this?

Through the Permissions section I was only able to define if the user can add, edit, delete content and that's not enough.


texts: Multi step registration form fields not being saved

texts:
The user accounts have been extended with many fields.

I built a custom module which converts the registration form into a multi-page form.

In hook_register_validate I compile all the values from across the pages into $form_state['values']. Dumping this array shows that all the values are present

Then in my submit handler I do this:

function MYMODULE_register_submit(&$form, &$form_state) {
    // Clean values
    form_state_values_clean($form_state);

    // Save initial email
    $form_state['values']['init'] = $form_state['values']['mail'];

    // Build a user from the form state values
    $account = $form['#user'];
    entity_form_submit_build_entity('user', $account, $form, $form_state);

    $account = user_save($account);
}

The account is created, but for some reason the majority of the fields are missing!

They go missing after the entity_form_submit_build_entity call even though they are present in $form_state['values'].

All of the text fields are being saved, but none of the select or checkboxes. Also, the profile picture is saved but none of the other files.


texts: Can't loop through $form_state->setErrorByName?

texts:
I want to display an error message if the form field is empty.

  public function validateForm(array &$form, FormStateInterface $form_state) {
      $entry = array(
        'name' => $form_state->getValue('name'),
        'lastname' => $form_state->getValue('lastname'),
        'cardnumber' => $form_state->getValue('cardnumber'),
        'month' => $form_state->getValue('month'),
        'year' => $form_state->getValue('year'),
        'cvv' => $form_state->getValue('cvv'),
    );
    foreach ($entry as $key => $value) {
     if (empty($value)) {

      $form_state->setErrorByName($key, $this->t('cannot be empty.'));

        }
     }
  }

but I only get:

  cannot be empty.

If I use instead:

foreach ($entry as $key => $value) {
  if (empty($value)) {

    drupal_set_message(t('<b>%key</b> cannot be empty.', ['%key' => $key]), 'error');

    }
}

Results how I want it:

  name cannot be empty.

  lastname cannot be empty.

  cardnumber cannot be empty.

  month cannot be empty.

  year cannot be empty.

  cvv cannot be empty.

Except the problem here is that the form input box does not become highlighted in red.

How can I make it loop through the first method? or is it like that by design?


texts: Can Drupal be used for hierarchical multi-site?

texts:
Can you use Drupal to make a site hierarchy?
The main reason would be managing permissions and general connections between sub sites, like the following one:

                       Site 1
        Site 2         Site 3         Site 4 …
    Site 5   Site 6                   Site 7 …


texts: Allows authenticated users to tag content

texts:
Administrator can add tags/Term reference to any content types.
How can I give permission to authenticated users so that they can tag on any content type where they have access for editing/adding?


texts:
I need to print Cart form view in drupal 8 site. I have installed Entity Print & Entity Print Views. I can generate pdf successfully using tcpdf pdf file or debug version does not considering css. How can I apply custom CSS to pdf file?
So far I have added below code in mytheme.libraries.yml

  print-styling:
   css:
     theme:
        css/print-style.css: {}

and in entity_print.libraries.yml

css:
layout:
  css/entity-print.css: {}
theme:
  css/entity-print.css: {}

And added custom css in entity-print.css, Enable Default CSS checkboox is not checked, added {{ entity_print_css }} brfore </head> in twig file. Still it is not working
Edited: Passing inline CSS is working for debug version but not in pdf


texts: Colorbox not working in user-login.tpl.php in Drupal 7

texts:
I am trying to open Forgot Password page in my customized login form through colorbox.

I customized my login page through this code (user-login.tpl.php):-

     $base_url = variable_get('base_url', '');

    // split the username and password so we can put the form links were we want (they are in the "user-login-links" div bellow)
    print drupal_render($form['name']);
    ?>

        Password
            *
            <a class="floatright normal-font" href="<?php print $base_url;?>/user/password?width=500&height=280&iframe=true" title="Forgot your password?" class="colorbox-load">Forgot your password?

        <input type="password" id="edit-pass" name="pass" size="60" maxlength="128" class="form-text required">

Enter the password that accompanies your e-mail.

  Forget your password? | Create an account

    <?php
        // render login button
    print drupal_render($form['form_build_id']);
    print drupal_render($form['form_id']);
    print drupal_render($form['actions']);

But the problem is that this line
<a class="floatright normal-font" href="<?php print $base_url;?>/user/password?width=500&height=280&iframe=true" title="Forgot your password?" class="colorbox-load">Forgot your password? doesn't open the colorbox.

Now, this link does open in page--user.tpl.php.

Any help please.


texts: How to create a block view containing data from another Drupal site?

texts:
I'm new to Drupal. I'm working on existing Drupal Website. This is a multi-site with single Drupal Setup.

There is a side-bar on the website that contains a view for News of website. I want to create another view like "News" and put it to below the "News" view inside the same block.

The new view will contain events instead of news and those events will come other websites (other websites is the sites from multi-sites, I have total 3 websites in multi-site setup).

Please help me to do this. Please let me know if I need to share more details.


texts:
I use Inline Entity Form to embed nodes within nodes.*

When editing these nodes, the embedded nodes appear as one block within Panels, so I cannot re-arrange the fields inside the embedded nodes:

I would like to split out the nodes into separate panes. I would also like to be able to re-arrange the fields in each embedded node using Panels drag-and-drop interface, as in this mock up:

How can I achieve this?

Mini Panels lets you get the first child node only.
Views Context gets all the embedded nodes. However, it will lump similar fields together. (e.g. all the image fields will be displayed in one pane).

*(Embedding nodes within  nodes is useful as each separate node can hold a group of fields. The effect is similar to Field Collection, but there are extra advantages such as being able to share content between nodes).


texts:
I have php 5.3.2 installed, which I need for Plesk11 on a virtual Server. Unfortunately drush needs 5.3.3. Is there no way to run it with 5.3.2?

Otherwise I have to compile a second php especially for drush, but I can't find any requirements.


texts: How to do a custom action when clicking on a file upload button

texts:
In my content type I have a custom widget added to an Image field. I need to open a custom popup when clicking in the image fields 'Choose File' button.

What I actually want to do is change the Image fields behavior like as in Entity Browser. I have created a new widget and added to that Image field, but I have no idea how to change the Choose File button to a button like entity browser.