texts: Display Taxonomy Field vs Default Taxonomy text w/out New modules

texts:
I have a node with taxonomy term reference fields. The taxonomy term has an image field. Without installing extra modules (I already have WAY more than I should have) is there a way to display a specific field for the taxonomy instead of the textual? And do it from a Childtheme?

I have the DEVEL module installed and after selecting the specific field I still get no ideas. I have dug around inside the field, looking through the various attributes of that field without any ideas.

Array > 'element' > '#field_name'
Array > 'element' > '#field_type' = 'taxonomy_term_reference'
Array > 'element' > '#items' > 'tid' = 4
Array > 'element' > '#items' > 'taxonomy_term' > Object = Recursion

It feels like I am 'right there' and should be able to grab something like ['element'][0]['field_taxonomy_term_image'] and render, but I can't find anything. I realize, after searching stackexchange, and google, that I could install Views and tweak around with it to get the desired output, but I know I've seen somewhere that you can (without coding) get the output of a taxonomy term to be another field than 'title' but I don't remember where I saw it.

UPDATE: I have found the path, but can't figure out how to output it. I did a DPR versus a KPR and just dug through the text. Here is what I see. Inside of template.php inside of a drupal-based custom function THEMENAME_field__content_type($variables) I dpr'd $variables['element'] and found this object/array/path.

[#object] => stdClass Object
    [field_faction_affiliation] => Array
        [und] => Array
            [0] => Array
                [taxonomy_term] => stdClass Object
                    [field_faction_icon'] => Array
                        ...
                        [uri] => public://Faction - Jinteki.pnp
                        [filemime] => image/png
                        ...

So I feel like... I could theoretically, create a new $variables['faction_icon'] to pass on to my tpl.php using the pieces above to generate an img tag. Any ideas?

UPDATE: After a bit more digging around I got this to dpr and output what I expected.

$variables['element']['#object']->field_faction_affiliation['und'][0]['taxonomy_term']->field_faction_icon['und'][0]

So... now the tough part is figuring out how to generate an image path from a URI... of which, I am fairly clueless, but I will start searching.

UPDATE: After tweaking the function listed above I get this to work.

$faction_icon_url = file_create_url($variables['element']['#object']->field_faction_affiliation['und'][0]['taxonomy_term']->field_faction_icon['und'][0]['uri']);
$output = "<img class='faction_thumb' src='". $faction_icon_url . "' />";
return $output;

Now I have to figure out how to make this image link back to the taxonomy_term like the original output of text did.


texts:
I have created custom views handler for adding custom field in view. I have used code below to create custom handler.
/**
 * Implements hook_views_data().
 */
 function my_module_views_data() {
   $data['custom']['table']['group'] = t('Custom');
   $data['custom']['table']['join'] = array(
     // #global is a special flag which let's a table appear all the time.
     '#global' => array(),
   );

   $data['custom']['custom_handler'] = array(
     'title' => t('Custom Handler'),
     'help' => t('Custom Handler.'),
     'field' => array(
       'handler' => 'views_handler_custom_handler',
       'click sortable' => TRUE,
     ),
   );

   return $data;
}

/**
 * A handler to provide a field that is completely custom by the administrator.
 *
 * @ingroup views_field_handlers
 */
 class views_handler_custom_handler extends views_handler_field {
   function query() {
     // do nothing -- to override the parent query.
   }

   function option_definition() {
     $options = parent::option_definition();

     // Override the alter text option to always alter the text.
     $options['alter']['contains']['alter_text'] = array('default' => TRUE);
     return $options;
   }

   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);

     // Remove the checkbox
     unset($form['alter']['alter_text']);
     unset($form['alter']['text']['#dependency']);
     unset($form['alter']['text']['#process']);
   }

   function render($values) {
     // Render your content.
      $download_count = db_query("SELECT count(cl.id) FROM {custom_table} cl")->fetchField();
 // Render your content.
 return $download_count;;
   }
}

Above code shows the custom field in view. I have added the field in view and rendered the view in table format and enable sortable option for custom field but it not sortable and throws the below error.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'unknown' in
'order clause'

Kindly share correct way to do this.


texts: Flood table not respecting X_FORWARDED_FOR

texts:
The flood table IPs are listing the IP of the load balancer, not the one of the request, which is in the X_FORWARDED_FOR header.

I have the 'reverse_proxy' set to TRUE in setting.php, and it works with the CDN as expected, but not with the flood table.

The site hosted at AWS using the CloudFront CDN.

How can I make the flood table look at the IP reported in the X_FORWARDED_FOR header?


texts: how to get XML content over HTTP request?

texts:
I'm building a module and I need to  get XML content over HTTP request.

The idea is to create nodes programmatically with the retrieved data from the xml file.

Can I do this?


texts: Massive conditionals in field_sql_storage_field_storage_load query

texts:
In Drupal 7, I've been struggling with a slow local (and remote dev) site for the past few days. If I try to edit a field on a Message entity type, it hits my 720 sec execution time limit (normally 180 secs, I wanted to see if it would ever finish.)

I have traced the slowness back to field_sql_storage_field_storage_load in field_sql_storage.module.

That function loops over fields to obtain entity ids;

foreach ($fields as $field_id => $ids) {

Heres were the fun starts. I have a handful of field_id's (100-odd) but on the field_id's that I've var_dump'ed, there have been over 30,000 id's!

Ie;

array (size=85)
  2 =>
    array (size=38942)
      0 => string '1' (length=1)
      1 => string '2' (length=1)
      2 => string '3' (length=1)
      3 => string '4' (length=1)
      4 => string '7' (length=1)
      5 => string '8' (length=1)
      6 => string '9' (length=1)
      7 => string '10' (length=2)
      8 => string '11' (length=2)
      9 => string '12' (length=2)
      <snip> ... goes for 30,000 id's

Another way to look at it, is inside the query that it is trying to execute;

AND (entity_id IN (:db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4, <snip> all the way to db_condition_placeholder_38838

Unfortunately, the site is still slow to output my var_dump's, so there is something slowing it down a lot before it even gets here.

What is happening here? Why are we having to perform such massive conditions in our queries?

It doesn't appear to happen on the production site, but maybe thats because production site uses memcache? Might not even use this function at all.

Would love any help, thanks.


texts: Convert address to multi value during migration

texts:
I have a migration that imports data into my address field and it works perfect.

  field_address/locality:
    -
      plugin: get
      source: city
  field_address/postal_code:
    -
      plugin: get
      source: postalcode

The problem I am running into is that some data from my source has multiple values in the city so I need to add some logic that if it has multiple cities, create 2 address field values (multi-value).

I was thinking to make a destination plugin. As a proof of concept I tried to edit Drupal\migrate\Plugin\migrate\destination\Entity::getEntity() with the below options but none of them worked:

$row->setDestinationProperty("field_address/locality", ['Chicago', 'Oakbrook']);

$row->setSourceProperty("field_address/locality", [0 => ['value' => 'Chicago'], 1 => ['value' => 'Oakbrook'], []]);

$row->setDestinationProperty("field_address/0/locality", 'Chicago');
$row->setDestinationProperty("field_address/1/locality", 'Oakbrook');


texts: Block changes do not save in admin/structure/block/ page

texts:
I have a large number of blocks in a Drupal website. Now I can not save changes in region and order of blocks in admin/structure/block/ page.

There is no message at the top of the page, no Javascript error in console and no error in the error log of my cpanel.

I have increased max_input_vars in php.ini file to 5000 or upper and checked the changes in admin/reports/status/php/ to be sure about it but still block changes does not save.

How can I get out of this problem?


texts: How do I trigger a modal from a template that points to a controller returning an AJAX response

texts:
I am trying to trigger a modal from a twig. The path of the modal is a controller that returns an AJAX response as below:

Routing code

usgbc_myaccount.get_badges_evidence_controller:
path: '/account/get-badges-evidence/{badge_type}'
defaults:
_controller:
'\Drupal\usgbc_myaccount\Controller\GetBadgesEvidenceController::getEvidence'
_title: ''
 requirements:
_permission: 'access content'
_format: 'html'

Controller code

namespace Drupal\usgbc_myaccount\Controller;

class GetBadgesEvidenceController extends ControllerBase
{
/**
* @return AjaxResponse
*/
public function getEvidence($badge_type)
{

    $options = [
      'width' => '50%',
    ];

    $response = new AjaxResponse();
    $response->addCommand(new OpenModalDialogCommand(t('Modal title'),
 $badge_type , $options));

    return $response;
}
}

Call to router from twig template

{{ 'Read more'|t }}

When I click on the link I get the response in JSON in text area on another page. What is missing? It the approach correct? Any help will be appreciated.

Thanks


texts: How to on Multisite manage users over 1 site

texts:
My client need 13 Pages with different domains, so we decided to make different DBs with same codebase. Now, he want to manage the users (admin, editors) over 1 site, so he can select which user has access to which site.

We tested CAS which works so far but i'm not able to define which user has access to which site.

How can I do that?


texts: Commerce Backoffice does not delete product variation TYPE

texts: When I add a new "Product variation TYPES" with Backoffice it creates a new "Content type" in Drupal. But if I want to delete some "Product variation type" it does not delete the matched content type. Is it OK? Do I have to delete it by myself? Or am I going something wrong?


texts: How to set the file status of files uploaded through theme settings to permanent?

texts:
I have been trying for a week to get image files uploaded to a Drupal server through the use of "managed_file" theme settings to remain on the site longer than the default 6 hours. I have visited the Stack Overflow/Exchange forums before
(https://stackoverflow.com/questions/8793518/set-file-status-permanent-for-appearance-settings-file-upload)
(Uploaded images in theme settings is going to be lost)
and have done my best to implement the provided solutions, but the uploaded files always disappear after 6 hours.

Here is one of the managed_file fields which I wish to make permanent:

$form['mentor_settings']['global_settings']['header_settings']['header_background_image'] = array(
      '#type' => 'managed_file',
      '#title' => t('Header Background Image'),
      '#default_value' => theme_get_setting('header_background_image'),
      '#description' => t('This image will match the full dimensions of the header in the back.'),
      '#upload_location' => 'public://themesettingspictures',
      '#upload_validators' => array(
        'file_validate_extensions' => array("png jpg jpeg gif"),
             ),
  );

The file is properly moved to the specified folder. I have attempted to set the file status to permanent using the code provided in the above links, but it has never worked.

I would like to know if anyone can show me what function will set the file status for me AND can show me how to write it for the setting above, with its very long array "path". The examples I have tried to imitate have always been for 1st level theme settings, but my theme has three different levels of settings, so I'm never sure if I'm referencing my individual settings properly when trying to change file status.

One more note: I have been a self-taught front end Wordpress and Drupal web designer for a year now, but my knowledge of PHP is weak and so I am usually unable to code and back-end functions on my own. If you simply tell me to "use" a certain PHP function, I will have no idea how to apply it within the context of Drupal. If you respond to my post with references to PHP functions, please explain if they must be in a certain file (theme-setting.php vs template.php) and provide any other Drupal contextual information.


texts: How to show the ip address in revision listing?

texts: When I see all the revisions of a particular node through in my site, say, http://www.mysite.com/node/1/revisions,  I see an html table representing our data having two columns mainly REVISION and OPERATIONS. I have a requirement to add another column called IP Address from where the content originated for tracking purpose. I have already added a field in ip_address in the database, but don't know how to show the ip address in the revision listing? Plz help.


texts: Node edit form with embedded form not executing custom submit handler

texts:
I'm porting a module that currently works with Blocks/BlockForms to Paragraphs/NodeForms. I'm inserting an embedded form inside a Paragraph inside a Node Edit page using a
hook_field_widget_entity_reference_paragraphs_form_alter. The general structure where the form gets inserted is:
$form['field']['widget'][0]['settings'][form here]

After this the form displays as expected on the node edit page.
The inserted form goes through a number of #process steps. The element in question is a select form that when the button underneath it is pressed, is supposed to retrieve some data via a custom submit handler and place it on the page with ajax:

The array for this element looks like this:

You can see the custom submit handler that is supposed to fire when 'Select Segment Set' is pressed
After debugging, I've found that the entire NodeForm appears to be submitted to the backend, and the only handler that is found is from some other field that uses ajax. In short 'updateSegmentSet' is never discovered as a submit handler. When I debug the original module based on block/blockforms, I do see the correct submit handler being discovered. Now in the latter case, of course a blockForm is submitted to the back end with the correct plugin. Given that this is basically a form within a form within a form, is there something special I have to do to get the custom submit handler to run? I've read a few things online e.g. the 'settings' key and '#tree' = true.
EDIT
The Ajax property looks like this:
      '#ajax' => [
        'callback' => [$this, 'updateSegmentSetAjax'],
        'wrapper' => $wrapper_id,
      ],

  public function updateSegmentSetAjax(array &$form, FormStateInterface $form_state) {
    $button = $form_state->getTriggeringElement();
    // Go one level up in the form, to the widgets container.
    return NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -2));
  }

As best I can tell, this is never called either.


texts: Same session variable retrieved in different blocks not stable

texts:
I have a module that have three blocks.

Block No 1 sets the session
Block No 2 gets the session
Block No 3 remove the session

Each block is assigned to a different page.

Now, for some reason this is not working well. I spent the last hours understanding where my mistakes are. The problems are:

I don't always see the session value on block 2
I don't see the markup in block No 3.
The session is not removed in block No 3.
The block doesn't always get set in block No 1

This is the block code:

Block 1:

namespace Drupal\achva_sso\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Class SsoSessionBlock
 * @package Drupal\achva_sso\Plugin\Block
 *
 * @Block(
 *     id = "achva_sso_session_block",
 *     admin_label = @Translation("Example achva sso session block block")
 * )
 */
class SsoSessionBlock extends BlockBase {
    /**
     * {@inheritdoc}
     */
    public function build(){
        $value = time();
        $session = \Drupal::request()->getSession();
        $session->set('name', $value);

        return [
            '#type' => 'markup',
            '#markup' => $this->t('The output of super SsoSessionBlock block.'),
        ];
    }
}

Block 2:

<?php
/**
 * Created by PhpStorm.
 * User: david_s
 * Date: 14-Nov-18
 * Time: 2:07 PM
 */

namespace Drupal\achva_sso\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Class SsoSessionBlock
 * @package Drupal\module_hero\Plugin\Block
 *
 * @Block(
 *     id = "achva_see_sso_session_block",
 *     admin_label = @Translation("Example achva see sso session block block")
 * )
 */
class SsoSeeSessionBlock extends BlockBase {
    /**
     * {@inheritdoc}
     */
    public function build(){
//        $session = \Drupal::service('user.private_tempstore')->get('achva_sso');

        $session = \Drupal::request()->getSession();
        $details = $session->get('name');

        return [
            '#type' => 'markup',
            '#markup' => $details,
        ];

//        $request = \Drupal::request();
//        $session = $request->getSession('name');

//        return [
//            '#type' => 'markup',
//            '#markup' => $session,
//        ];
    }
}

Block 3:

<?php
namespace Drupal\achva_sso\Plugin\Block;
use Drupal\Core\Block\BlockBase;

/**
 * Class SsoSessionBlock
 * @package Drupal\achva_sso\Plugin\Block
 *
 * @Block(
 *     id = "achva_delete_sso_session_block",
 *     admin_label = @Translation("Example achva delete sso session block block")
 * )
 */
class SsoSessionDestroyBlock extends BlockBase {
    /**
     * {@inheritdoc}
     */
    public function build(){

        $session = \Drupal::request()->getSession();
        $details = $session->remove('name');
        if($details !== null){
            $a = 'logged in';
        }else{
            $a = 'logged out';
        }

        return [
            '#type' => 'markup',
            '#markup' => '
sss'. $a .'
 ',
        ];
    }
}

I am totally lost. Any help would be great. Tried to use simple sessions doesn't work well either...


texts: flexslider is failing on version recognition and perms

texts:
Updated via drush, flexslider module v.7.x-2.0-alpha3 is installed.
Installed latest version of library 2.3.0, released 17 days ago as of the time of this writing.
Getting drupal pesky error about version not recognized, so decided to downgrade library to 2.2.2, same error.
Moreover I am getting following errors in status report:

Warning: fopen(sites/all/libraries/flexslider/jquery.flexslider-min.js): failed to open stream: Permission denied in _flexslider_requirements_library_installed() (line 212 of /var/www/asflorida.com/sites/all/modules/flexslider/flexslider.install).
Warning: fread() expects parameter 1 to be resource, boolean given in _flexslider_requirements_library_installed() (line 213 of /var/www/asflorida.com/sites/all/modules/flexslider/flexslider.install).

Before somebody tells me that this is a perm issue: I checked thoroughly and perms are 775 throughout and ownership is correct.
Either alpha 3 is not working with older library or viceversa.
Thanks in advance.


texts: How do I Improve Drupal 7 Forum Performance?

texts:
I am working on a website that has 60k+ forum topics and it is extremelly slow. The problem is that the core forum module uses the following query

SELECT ncs.last_comment_timestamp AS last_comment_timestamp
, ncs.last_comment_uid AS last_comment_uid
, CASE ncs.last_comment_uid WHEN 0 THEN ncs.last_comment_name ELSE u2.name END AS last_comment_name FROM node n
INNER JOIN users u1 ON n.uid = u1.uid
INNER JOIN forum f ON n.vid = f.vid AND f.tid = '22'
INNER JOIN node_comment_statistics ncs ON n.nid = ncs.nid
INNER JOIN users u2 ON ncs.last_comment_uid = u2.uid WHERE  (n.status = '1') ORDER BY last_comment_timestamp DESC LIMIT 1 OFFSET 0

I saw that this query was the problem because after running the top command I saw that mysql was consuming 150%+ CPU so I ran a show full processlist that showed that the query above was always in the following state

Copying to tmp table    SELECT ncs.last_comment_timestamp AS last_comment_timestamp, ncs.last_comment_uid AS last_comment_uid, CASE ncs.last_comment_uid WHEN 0 THEN ncs.last_comment_name ELSE u2.name END AS last_comment_name\nFROM \nnode n\nINNER JOIN users u1 ON n.uid = u1.uid\nINNER JOIN forum f ON n.vid = f.vid AND f.tid = '22'\nINNER JOIN node_comment_statistics ncs ON n.nid = ncs.nid\nINNER JOIN users u2 ON ncs.last_comment_uid = u2.uid\nWHERE  (n.status = '1') \nORDER BY last_comment_timestamp DESC\nLIMIT 1 OFFSET 0

The result of the explain command is

id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1       SIMPLE  f       ref     PRIMARY,tid     tid     4       const   30030   Using index; Using temporary; Using filesort
1       SIMPLE  n       eq_ref  PRIMARY,vid,node_status_type,uid        vid     4       drupal.f.vid    1       Using where
1       SIMPLE  ncs     eq_ref  PRIMARY,last_comment_uid        PRIMARY 4       drupal.n.nid    1
1       SIMPLE  u2      eq_ref  PRIMARY PRIMARY 4       drupal.ncs.last_comment_uid     1       Using where
1       SIMPLE  u1      eq_ref  PRIMARY PRIMARY 4       drupal.n.uid    1       Using where; Using index

Any ideas what to do to improve the performance here ?

Thanks


texts: How to generate a list of which Features are enabled in which Spaces?

texts:
I'm running a Drupal 6.x site with Organic Groups, Features, and Spaces, and I'm interested in generating a list of which Spaces have which Features enabled. Preferably a table, with Spaces along the Y axis, and Features along the X axis.

Any ideas regarding how to generate this? I can generate a list of Group Spaces using Views, but can't find a field for the enabled Features.


texts: Does ajax used in views call preprocessing hooks?

texts:
I have a view with a bunch of fields and I'm styling those fields in:

views-view-fields.html.twig

In my .theme file I'm also using a preprocess function to pass additional variables to the above template.

function theme_preprocess_views_view_fields(&$vars) {
  $vars['my_var'] = 'hello';
}

So in the twig template, I'm able to do something like:

{% for field in fields -%}
  {{my_var}}
{%- endfor %}

This is working like a charm for the first loaded fields, but when I hit "Load More" or I use exposed filters to filter down the view, the other loaded elements will not have my_var.

Now, "kinting" my_var directly in the template file. I saw that my_var is NULL for all other elements loaded after with Ajax and this made me think that the problem is with
theme_preprocess_views_view_fields being called once, the first time the page is loaded and completely being ignored from the Ajax call.

Shouldn't this preprocess be called and handled by the Ajax call Drupal is doing on the view itself?

If not, is there a way to query Drupal to re-run this hook when other elements are loaded?

Thanks!


texts: Changes in view template for a blog doesn't show up

texts:
I have a drupal 6 site on production server.

There is a blog, which has view setuped to display list of blog entries, but the default layout is broken. I have two options to proceed:

adjust styling on existing default template
create views-view-blog-tpl.php and add my custom layout there

So I choose option two and added a views-view-blog-tpl.php, upload it via ftp, on Edit View page I re-scan template files and Drupal successfully finds my template. Then I flush all caches and reload my view page - but no changes are show up. It's still showing me default view template with broken layout.

Is there something that I missed? Any additional step to make changes in my blog view template to show up?

Any help appreciated.


texts:
Are there any way to get site's base URL value in a token within view to use in its header and field(s).

My local developments is on drupal installation in a sub-directory while on server it is on a domain.


texts: How to create a view of nodes that are referenced by a node that references the current node?

texts:
I have three content types: patient, patient medication, and physician.

Using the Node Reference module, patient medication references the patient content type and the physician content type. How can I create a view with a contextual filter that does the following: When I view a physician node, I want to view all patients that the physician has interacted with. Using the two Node Reference fields in the patient medication content type, how can I display a block of unique patients that the physician has prescribed a medication to?

I basically have it set up like a relational table:
Patient <-- Patient Medication --> Physician  (The arrows represent the node reference)


texts: Multiple translations of Paragraph content - EN / ES work, FR displays EN

texts:
I have gone through the documentation several times and started from scratch with a new EN node, translated Body and Accordions to ES (works!), then back to the EN, Translate, FR, add all the same content en français, but the View (even for me logged in) is Body in FR, Accordions in EN. On the Edit screen it's all in French.
I think I would understand if neither language worked (previously when Paragraphs were not set up properly, the last language entered would take over all pages).
Any ideas?


texts: Multi site installation with cPanel showing Warning: symlink() [function.symlink]: File exists in

texts:
I want create multi site with drupal 7.I just started with below link http://drupal.org/node/960934 After setup show an warining

Warning: symlink() [function.symlink]: File exists in /home/ioss/mydomain/index.php on line 5

The PHP Code is symlik is given below

symlink( '/home/ioss/ashokks/', '/home/ioss/ashokks/test1/' );

in the above code snip drupal installed under the directory "ashokks" and test1 is the multi-site subdomain.

Thanks in advance


texts: How to use different meta details for English frontpage

texts:
I have set up a multilingual website using D7.
Now I have two front pages:

Chinese
and English.

I have added meta info for front pages in:

Configuration -> Search and Metadata -> Meta Tags

But the same meta is coming for both Chinese and English. I need separate metadata for both.

Is it possible?

Thanks


texts:
I am using the webform localization module for string translation of my webform components. I have created a custom module that outputs the data but can not get the translation to work. I am using the t() function as follows passing in the string, the language and the context of component 1 title on node id 50

t('New radios', array(), array('langcode' => 'fr', 'context' => '50:1:#title'))

Any thoughts on where I am going wrong would be great.


texts: 8 How to set a value for select list, While using $entity->set('field_name_type_select_list', ["Se_the_optional_value"]); Programmatically?

texts:
The following line of code I am trying to use,

use Drupal\Core\Entity\EntityInterface;

/**
 * Implements hook_ENTITY_TYPE_update().
 */
function mymodule_node_update(EntityInterface $entity) {
  switch ($entity->getType()) {
    case "article":
      $entity->set('field_set_color', ["red","green"]);
      break;
  }
}

Why not able to set the value for a select list like this?


texts: Is it possible to login as / switch to a specific user using their password hash from the DB?

texts: I don't particularly want to enable Devel on my production environment to gain the Switch Users block. Is there a way to switch users without any additional php code?


texts:
I'm not sure if that is really the proper way of wording what i'm looking to do, but perhaps it will at least peak some curiosity.   I"m a bit uncertain how to explain it, so I'll do my best.  Just when I think i'm getting a handle of contextual filters a new challenge comes along, this one has me a bit stumped, I'll try to explain....

I have two content types.   A   B

A can reference B  as many values as it wants.  so I get a result like this:

A-
 -

B1
B2
B3

I have a view which lists all of the A nodes...

A1
A2
A3

What I'm attempting to do is this.  When looking at the page that shows the list of A's.
www.example.Alist.  I'm wanting to show in a block on the left, a cumulative list of all the
B nodes that A referenced. (without duplicates of course)  hope that makes sense to someone.  Having difficulty wrapping my head around how to go about it.  Thanks much for any guidance.


texts:
What I tried

    $sql="select * from project_status where node_id=".$vid." and ".  strtolower($field_progress_flags)."!='' and ".  strtolower($field_progress_flags)." IS NOT NULL";
    $query=$sql;
    $array = array();
    $result = mysql_query($query);
    while ($object = mysql_fetch_array($result)) {
        $array[] = $object;
    }
    mysql_freeresult($result);
    echo "<pre>";
    print_r($array);

the actual sql query is  select * from project_status where node_id=385 and draft!='' and draft IS NOT NULL

here am not getting any data
what am doing wrong here?


texts:
Hi guys (and gals) I'm trying to create a simple enhancement to one of my modules .inc files and am messing something up somewhere, and was hoping someone with sharp eyes can point it out. Even though it is extremely easy to just insert one line into the contrib file, do to our companies "best practices" I need to add this in another way.

I am trying add one extra variable into the $services array of the gigya_get_networks function, the function in gigya.inc is

function gigya_get_networks() {
  $services = array(
    'facebook' => 'Facebook',
    'myspace' => 'MySpace',
    'twitter' => 'Twitter',
    'google' => 'Google',
    'yahoo' => 'Yahoo',
    'aol' => 'AOL',
    'blogger' => 'blogger',
    'wordpress' => 'WordPress',
    'typepad' => 'typepad',
    'liveJournal' => 'liveJournal',
    'hyves' =>  'hyves' ,
    'veriSign' => 'veriSign',
    'linkedin' =>  'LinkedIn',
    'liveid' => 'Windows Live ID',
    'openid' => 'OpenID',
    'orkut' => 'Orkut',
  );
  return $services;
}

I created a new module in /custom/utilities/gigya_enhancements with the following

gigya_enhancements.info

name = Gigya Enhancements
description = Provides Gigya enhancements.
package = Gigya
php = 5.2

files[] = gigya_enhancements.module

dependencies[] = gigya

version = 7.x-3.1
core = 7.x

and a gigya_enhancements.module with the following

<?php
/**
 * Implements hook_get_networks().
 */
function gigyas_enhancements_get_networks() {

  // Add Vkontakte to existing services.
  $services = array(
    'vkontakte' => 'VKontakte',
  );

    // shortcode: return $services['vkontakte'] = 'VKontakte';

  return $services;
}

But I'm not returning my additional array parameter, would someone mind explaining what I (evidently) have done wrong? Is it something to do with
me trying to operate on an *.inc file maybe?

Thanks everyone.


texts: Node form that defines fields based on another node

texts:
I have two content types (Unit and Scheme of Works). In Unit, I have a field (field_lo) that allows the user to create an unlimited number of entries.

In Scheme of Works, I need to associate other field values related to the field_lo entries from Unit. Effectively, in Scheme of Works, I need to be able to dynamically add a number of fields to match the quantity of the field_lo entries in Unit.

Is this possible? If so, how?

Thanks


texts: Should I bother using Taxonomy when I am using Node Hierarchy as well?

texts:
I am getting rather bogged down with the structure of my site. I have a taxonomy setup as well as node hierarchy, but I wonder if a taxonomy structure is kind of pointless now that I am using node hierarchy. Should I perhaps use it just for tagging and not any structure?

The main issue I am having is the URL aliases: they are being doubled up. It seems I am going to have tons of duplicate pages, now.


texts:
I want to use Zopim chat for Drupal 8, but there is no version for it. However, I see something is done about it on https://www.drupal.org/node/2624230.

Does it mean I can use it safely on Drupal 8? Is it OK to use patched up Drupal 7 third-party modules on Drupal 8?


texts:
I'm using Drupal (version 7) for the first time and I have two content types, Landing Page and Article Page, each with their own templates page--landing_page.tpl.php and article_page.tpl.php respectively.  The only reason I have two content types is because each content type needs to be displayed differently on the website.

I have several contents of the type Landing Page which I would like to display with the page--article_page.tpl.php template.  So now I have the troublesome task of manually converting each of these content types to Article Page.

Is there a more effective way for a user to select the template he wants to use for a content instead of changing content types?


texts:
I am trying to get the SUM of a group of fields in a view. We hold events and I wanted to create a view that showed How many degree types by total. See below image for quick idea.

So, If there are 20 MD's, I want one row that shows MD's with a total of 20 - versus 20 rows of MD's.

I have look at views aggregation but since it isn't a number I can not see it working. I have also looked at view calc but that just shows a total at the bottom.

I am looking to figure out the best way to handle this. If I have to custom code any help pointing me in the right direction would be greatly appreciated!


texts:
What hook is the equivalent in Drupal 7 for hook_widget_settings($op, $widget), used in Drupal 6?

What hook is the equivalent in Drupal 7 for hook_widget_settings_save(), used in Drupal 6?


texts: Token to show all the comments including comment body for a node

texts:
I am trying to set up a notification email using rules that will email a forum topic with all the comments including the comment titles and body.

The Message text I have so far is:

  A new forum comment has been posted by
  [comment:author:profile-main:field-name] with the following details

  [comment:node:title]

  [comment:node:body]

  Comments:

  [comment:node:comments]

However, the final token, [comment:node:comments], only shows the comment titles and not the comment body.

Is there a way that I can show the full list of comments including the comment body?


texts: How to get count in views when group by some field?

texts:
I have view which display results based on taxonomy field grouping:

And results look like below :

I am trying to display count of each group in brackets next to Topic field, Is that possible to achieve with this kind of view. Please suggest.

Thanks!


texts: referencing a field in a node in hook_node_api

texts:
I am using drupal 6. I have a simple question:

Here's a snippet of code from my hook_node_api function:
...

case 'presave':
    {
        if($node->type == 'example')
        {
            if($node->content['field_alert']['#value'] == TRUE)
            {
                //do something
                drupal_set_message('Your update will be emailed out.');
            }
        }
    }
   break;

I want to reference the value of a field named field_alert inside of a node type "example" but I'm doing it properly since its not working. How do I do this?


texts:
How do I access the view block name?

function <theme_name>_theme_suggestions_views_view_alter(array &$suggestions, array $variables) {

 // print_r(array_keys($variables));
  if (isset($variables['view'])) {
    $view_id = $variables['view']->id();
    $view_block = 'testing';
    array_splice($suggestions, 1, 0, 'view__bundle__' . $view_id . '__' . $view_block);
  }
}


texts: How to add content type as a menu item child without displaying the link in the menu?

texts:
I recently found menu block module, which displays my submenu very nicely. Here's the menu hierarchy:

Home
About
News & events
-- News
-- Events
Contact

So when I go to the News & events page and from there to the News page the submenu displays just fine. But when I open a piece of news in the News page (which is a view displaying content from the News content type) the sub menu disappears. I'd like to show the submenu like the piece of news I just opened would be a child of News menu item. The problem is how to this without actually displaying all the news links in the menu. I know that there's a way to disable menu links but haven't found a way to disable them by default when adding new content.

What would be the best way to implement this kind of hierarchy?


texts: How do I replace the SQL query of a view?

texts:
I need to override an SQL query of a view. I'm using Drupal 7 and Views 3.x-7.x-alpha1.

I understood I can write my own query with views_pre_execute. I followed the instructions mentioned here: http://blog.raisedeyebrow.com/2010/04/rewrite-a-views-query/.

I added this piece of code to my custom module.

function alterquery_views_pre_execute(&$view) {
  dsm($view);
}

Following the instructions, when I look for the value of $view->build_info['query'], I see that the type is object of a class SelectQuery.

How am I able to get total control of the query and use my own select statement?
I know that with hook_views_query_alter() I can modify a keyed array, but I would rather write the select statement from scratch.


texts: How to remove all users and their content from a specific role programmatically ?


texts:
I try to install drush using the following command:

pear install drush/drush

I get this error message:

  No releases available for package "pear.drush.org/drush" install failed.

Then I try with sudo:

sudo install drush/drush

I get this error message:

  downloading drush-5.4.0.tgz …
  Starting to download drush-5.4.0.tgz (398,652 bytes) done: 398,652 bytes
  Could not rename /usr/bin/.tmpdrush to /usr/bin/drush copy(/usr/bin/drush): failed to open stream: No such file or directory
  ERROR: commit failed.

I installed pear, and added the pear.drush.org channel. What is wrong?

I realize that my question was not very clear. I was trying  to install drush using pear on OSX Mountain Lion and I got those errors. Anyway I managed to accomplish my task another way, by installing "homebrew" package manager and following a few steps from this tutorial (step 8 and 9).

Update: an even simpler way to install drush using homebrew:

brew install drush

That's it.


texts: Block that shows nodes based on node type

texts: I want to create a module that displays nodes of a certain node type. Can this be done, and can anyone point me to a place where I can find how to do this?


texts: View should show related articles from shared reference field - relation from a relation

texts:
I have two content types: Article and Magazine. in Article there's an entity reference field to Magazine, field_related_magazines.

On my website, when an article is shown, I would like to show a list of related articles that share the same magazine.

When I make a new article, I can choose the magazine edition in which the article appeared.
Then, on the bottom of the node page, all other articles should be listed.

The thing I tried:

Make a views block 'Magazine related items' that lists Article titles and place the block on the Article pages.

Set the context for the block to work: Advanced>Contextual Filters>Content ID>Provide default value>Content ID from URL

Set the relation: relationships>Content using field_related_magazines (relate each Content with a field_related_magazines set to the content item.)

However, this only shows the current articles' title, not the titles of all other articles that share the same magazine.
How would I get all the others?


texts:
Other modules doing well but not actively developed.

How to make Similar By Terms works without vocabulary?


texts:
Is there an easy way to list someone's "role" sort of like a badge, next to their username?

I dont want any point system or anything like that


texts: How to create a single page with a jump select menu?

texts:
I need to create a page with a single jump select menu. Once the user makes a selection he/she will be redirected to a view page where the selection will be used as contextual filter

Can I do it with the webform module? What other option do I have?

I've found this one: http://drupal.org/project/jump but just a dev version for d7.


texts: Create a node Programmatically having Composed Field

texts:
I have a content type having composed filed (used Composed Field module for this).

How can I create a node programmatically with composed field values?


texts: Glossary view preview works fine but it is not visible on actual page.why?

texts:
I had cloned a glossary view but forgot to update the page path.

Later I deleted the cloned view. Now none of my newly created views work!
Preview displays properly but nothing is displayed on actual page.Please help me.

I tried clearing all caches,disabling/reverting the original glossary view ,disabling field group module as suggested in one of the post but nothing works.


texts: Display a code snippet based on a taxonomy term

texts:
I am trying to build a node file for a content type in Drupal 7.59. I have for example a field for a taxonomy term. There is only 2 terms Expert and Guest.
I want to display something on the node if this term reference choice is marked as Expert.

So I need to figure out how to write a line that checks for the value of the taxonomy term and then if it matches expert then it displays something but if it is guest it doesn't.

The field I have setup in my content type is:

Name of field: author type
Machine Name: field_author_type
Field Type: Term reference

The root taxonomy term is Author Type and the two terms are Expert and Guest.
Does anyone know how to accomplish this? I hovered over the taxonomy term I wanted to reference and it was /taxonomy/term/57/ Is 57 the actual number or do I find it elsewhere?

So far I have this which is not much and it doesn't work so it is wrong. I am really sucky at php.

<?php if ($content['field_authors_type']->taxonomy[57]): ?>
    Put what you want to display here
<?php endif; ?>


texts: Email notifcations based on specific dates i.e. employee anniversarries

texts:
We are utilizing Drupal 7 as an intranet application for our company. One of the content types of the app is a Views-based Employee Directory. Within this directory is a field detailing the employee's start of employment date.

My boss requests a feature implemented where we will receive notifications via e-mail in regards to upcoming anniversaries of employee start date, i.e. 1 year, 5 years, 10 years, etc.

Is this something I can create using Rules+Views? Thank you


texts: How to protect thumbnail and library images from media browser from being deleted?

texts:
I have a Drupal 7 site where authenticated users can create a webpage to raise money for a charity. They can add a picture from the media library using the media browser. However, if they delete their page, this deletes the thumbnail and the library image from the db and site.

I've tried the File Lock module, but that doesn't work. I've set the user permissions to where the images cannot be deleted; that doesn't work. The images are used in other places as well as the need to keep them library for future users.

Any suggestions?


texts: Complex order form presented as series of linked screens

texts:
[Somewhat new to Drupal Commerce and Webform; trying my best to construct this question in a clear way]: The project involves order forms for a combination of fee-charged workshops and also a series of no-fee workshops where the person needs to make 2 choices among 6 options but must rank them by preference (in case they can't get their top choice). So there are several kinds of choices the person needs to specify. Then the form needs to collect a wide variety of info, not just basic contact info. Finally it needs to collect payment for the items requiring it.

I already have a Webformbased structure that does all these things. (Although maybe not very efficiently.) It all exists on one page, using collapsible fieldsets to keep the initial view of the page simple and to have everything in one place. It makes sense to me, but for the new user I think it may be confusing.

I am thinking, it would be "better UX" if the various parts of this ordering process were divided into smaller chunks. I am thinking, either pages or maybe modal windows that are clearly and boldly identified as Step 1, Step 2, etc. and with the option to go back if desired. The results from each page or modal window would of course need to be compiled as part of the same order.

Is there a path to this sort of order form structure via existing modules, or is this a custom code project?


texts: Fraud detection on hotmail from Simplenews Newsletter

texts:
I send newsletters from my Drupal-7 website using Simplenews newsletter module.
But when a user has hotmail, the mail comes with a flag "Be careful. This sender is not approved by our controls for fraud detection."
I googled this and I saw that it has to do something with SPF but I don't understand what this is and what steps do I have to do to fix this issue.
Is there an option from administrator or a line of code I can use?
Thanks in advance!


texts: What is the Aegir make_working_copy SCM option mean?

texts:
If one creates a platform and chooses to preserve the working copy, does this initiate a .git clone that the aegir user from CLI, could update and merge branches to?

  Create a new platform:

    Drush make option:

      Normal - Discards SCM files
      Working copy - preserves SCM files

Where is the working copy directory?


texts: Git-like way of updating Drupal database

texts:
It's easy to update Drupal on the local / remote server using Git.

However, sometimes when I make modifications in the actual module settings or any other settings on my local server – those are recorded in a database and I can't then update them easily on the remote server.

At the moment I just export the whole Drupal database and then overwrite it on the remote server.

But is there any faster / easier Git-like way of doing that?

Maybe a special module? Or a special git-like service for Drupal databases / MySQL databases?

Thank you!


texts: Changing number of values on a field in installation profile

texts:
I am creating an installation profile with multiple fields. For a 'file' field I want to change the number of values. I have two questions about this.

Is this an field setting or an instance setting?
and what is the right way of changing this setting I tried these:

'number_values' => '2',
'max_value' => '2',
'max_values' => '2',
'values' => '2',
'value' => '2',

I can't find any of this on the internet. Any help and tips would be appreciated.


texts: Postal address field does not display in node

texts:
In drupal 7, I am using a 'postal address' field, with the widget 'Address autocomplete' for my node. A full address is obtained and saved every time a new node is created. However, it does not display the address on the node's page.

FYI, in the 'manage display' of the content type, the field is visible with the format on 'default' and the option is 'use widget configuration'. I have already tried the other option of deselecting the 'use widget configuration'.

Any suggestions?


texts: JS error(s) with Media-7.x-2.0alpha4 and CKEditor

texts:
I'm working on a production site that is using Media-7.x-2.0-unstable6, File entity-7.x-2.0-unstable6, and Wysiwyg-7.x-2.2 (with the CKEditor 3.6.3.7474 library installed). This is fine for inserting images into content types that have an image field, but I am attempting to upgrade Media to a more recent version that allows for WYSIWYG integration and insertion of images and other media directly into the body field.

I updated a local copy of the site to Media-7.x-2.0-alpha4 and File entity-7.x-2.0-beta1. Clicking on the "Add media" CKEditor button brings up the media browser in the normal way. Selecting an image and clicking on the "Submit" button brings up the "Embedding [filename]" dialog, but clicking on the "Submit" button does nothing. The firebug console shows TypeError: CKEDITOR.instances[this.field] is undefined in line 244 of /sites/all/modules/wysiwyg/editors/js/ckeditor-3.0.js (i.e. return CKEDITOR.instances[this.field].getData();).

I then disabled Wysiwyg and installed CKEditor-7.x-1.16. I still see the same behavior ("Submit" button does nothing), but now the JavaScript error is TypeError: Drupal.wysiwyg is undefined in line 45 of /sites/all/modules/media/modules/media_wysiwyg/js/media_wysiwyg.format_form.js (i.e. if (Drupal.wysiwyg.instances[field.key]) {).

I have disabled almost all contrib modules (except for those required by media and file_entity, and a few other innocuous ones that are required by some of the content fields), and the problem persists.

Since Media-7.x-2.0-alpha4, File entity-7.x-2.0-beta1, and CKEditor-7.x-1.16 on a Drupal 7 clean install work fine in my hands, I have a sneaky feeling that there may be cruft in the database that is screwing things up. However, my JavaScript is on the weak side, and I have no clue how Drupal and JavaScript interact, so I'm not sure where to even begin looking for the problem. Any hints on how I can solve this issue? (short of doing a complete rebuild of the site, which might not be a bad idea, actually...)

Thanks in advance!


texts: How is the hash for the files calculated?

texts:
I am taking an HTML snapshot of a node in Drupal 8 every day at 4 am. Every night a Cron job kicks off this process. I have a service that handles the entire process.
Everything works for now, but I am worried that the referenced CSS and JavaScript files will break due to the filenames changed by the aggregation process.
How does Drupal 8 decide the name of the aggregated files? How can I reliably point the references to the right filenames?


texts:
I am working on a multilingual site. I have to add HREFLANG attribute so that search engines like Google provide the proper response according to the language of the user and the region.

To implement this, I am using Alternate HREFLANG module which basically add HREFLANG attribute like this :

for all the three languages.

But I want to add language as well as region like this:

In the description of Alternate HREFLANG module description, they mentioned that if you want to alter this attribute, you can use  hook_language_switch_links_alter() and hook_html_head_alter() these hooks.

But when I dsm these, I didn't get the HREFLANG attribute.

Can someone help me to achieve this?


texts:
I am building a small web site which offers photography services. So, basically, I offer some services and these services do have some additional options (attributes). For example, service:

Single product on photo
Group products

And attributes:

Delivery: standart or rush (+$5)
Background color: white or black (+$1)

I found at least three ways how to add attributes, but a little bit confused which way is correct.

Using Taxonomy: Drupal Commerce - Product Attributes.
Using the Commerce Pricing Attributes module:

Drupal Commerce Pricing Attributes Module Installation and Configuration.
Drupal Commerce Tutorials - Products With Attributes.

My question: which way is correct and better for me? I like the Commerce Pricing Attributes module because it is more understandable, but as we can see this module is not very popular.


texts: When I publish to the front page, it shows part of the posts. My posts consist of just a file upload. However, the user must click on the post/click on the "Read more" button to see the file upload. How would I make Drupal display this file on the front page within the post?


texts:
What is a ctools plugin? Why would one want to use a ctools plugin ? What advantages does it have over the current hook system?

Is there currently documentation regarding usage of ctools plugin?

I often see contrib modules require ctools and depend on it. You see it in various different modules like commerce, feeds, etc.


texts:
I have a form that I want to render with a disabled field.

I've already tried:

$form_element['#node']->field_assoc_cnpj[0]['#attributes'] = array('disabled' => 'disabled');

And also to use it directly into the form array:

$form['#node']->field_assoc_cnpj[0]['#attributes'] = array('disabled' => 'disabled');

Nothing seems to work.

How can I do that?


texts:
I have installed the Facebook Share module on my Drupal 7 site and configured it accordignly to my preferences but it is not showing up on any of the pages I chose.

I just tested it even further by choosing it to be displayed every (full) node and it is showing up on basic pages, faq, and some more but not on my Ubercart products and one custom content type.  It does show up on another custom content type.

Any ideas?


texts: Find top and average value from input field text

texts:
H i have like 2000 nodes with field type - text field.

Purpose of that field is to be filled with best time that someone had on race. Format is something like 02:43:02 ( keep in mind that is text field and not time picker ).

Now i have been asked to show top 10 times, and average time, and im not sure how to do math here if that is text field?

Can views find top 10 times from text field?


texts: Translating taxonomy list name for a custom link in rewrite result field

texts:
Very hard to describe this problem in a title. Let me explain:

I have a taxonomy list named 'Meubelen'. I translated the name to 'Meubles' for the French version of the website.

I created a view of the terms in this list (an overview of categories). An image of a representative node is shown for each term. I like te rewrite the output of this image to a link directing to the taxonomy page. I can do this for one language, like this:

 meubelen/[term-name]

But this should change to

 meubles/[term-name]

when visiting the French side of the website.

How can I achieve this? There's no translatable field for this view that I can add and use as variable.


texts:
My Scenario:
One admin user is entering these information.
I have 3 content types: student, register, course.
Student is obvious, i.e. student_number, personal_info, etc
Course contains: course_name & course_costs, etc.
Register contains: ref to course, course_date, ref to students who attend this course.

My question: How would I go about calculating/working out costs per student, per course?

Do I need to use rules? I assume commerce is out of the picture, as one admin user is entering this information. Any direction would help. Thank you.


texts: How can I send email to recipients listed on another node connected using entity reference?

texts:
I have a content type Job Listing which defines characteristics of a job (position, full-time status, salary, etc).

I've also created an Entityform Type of Job Application which includes an Entity Reference field to a Job Listing node.

When Job Applications are submitted, I'd like the system, using rules or another contrib module, to look at the referenced job listing, grab any email addresses listed there and send them a notification that a new application has been submitted for their job posting.

I've installed Entityforms Notifications, Entity Rules, and their dependencies, but I'm swimming in configuration and can't figure this out.

Surely someone has done this before. Any help would be appreciated.


texts: Using searchapi module on a drupal multisite installation

texts:
We are setting up a Drupal multisite installation, which is going to look like

themastersite.edu
themastersite.edu/somethinglikethesubsite1
themastersite.edu/somethinglikethesubsite2 and so long

I've read some documentaition around Searchapi module, but I can't find out if there is a possibility to have, in themastersite.edu, a searchapi page that should search in all subsites ?

Any help or link, welcome.


texts: Simplenews does not apply templates and does not resend

texts:
I have a strange issue. Simplenews sends ok html formatted emails but it does not read the extra info I write in template. It actually doesn read them at all.

The second issue it doesn't resend no matter how much I try.


texts: Menu item with update text (title) in real time

texts:
I have a menu where one of the items (menu links) is a link to a view where I can see all comments that I have to moderate. Which I need is (if it is possible) to have the title of this link that change in realtime (or every time I load a page/node).

Think to my situation where I don't know how many comments I need to moderate so in this moment every X minutes I reload the page with all comments that I have to moderate. But this is frustating. So my necessity is to have a menu item like "Comments to moderate: FOO" where FOO is a number (from 0 to infinite) that I can calculate in realtime at every page load or every BAR minutes.

M.


texts:
I have created several views. These views have a block display. If I use these blocks in my template, the views are rendered with all the wrappers / divs.
In my block template, can I alter the output of the "content" variable to get only the values?
I tried to use different twig filters (striptags, trim, raw), without success. With these filters I get nothing.

Thanks.


texts: Recaptcha dissappears after form submission

texts: I am using webform with ajax and for spam protection I am using recaptcha module. Everything works fine when form is submitted once with all fields filled and recaptcha is also appearing on it. But when some validation error comes or recaptcha is left i.e. not filled the form appears again with error but their is no recaptcha field. Kindle tell me how to solve this as I am new to Drupal world. I am sure this isthis issue has been discussed before but I am unable to understand their solutions. Kindly give me a solution to solve this. I am using drupal 8.5.4.


texts:
Drupal 7, Views 3

I've got several views configured which display data over many years. The data is filtered by Year using a date field as filter criteria. For each year I have attachment views that I need to filter further by week. Rather than determining the exact dates for the weeks of each year and inputting them manually as filter criteria, I'm wondering if there is any way to add a filter criterion to filter by week number, i.e. week 1 thru week 52. That way the only date that needs to be set is the year for each view, and the rest happens automatically according to week number.

I am aggregating a lot of data by year and week in a table view where each column is an additional view attachment and trying to avoid having to manually enter the filters for week dates per year.

Does anyone have any advice/hints for me on this? Thanks very much.

Here is the code I am currently playing with:

function x_week_start($date) {
    $ts = strtotime($date);
    $start = (date('w', $ts) == 0) ? $ts : strtotime('last sunday', $ts);
    return date('Y-m-d', $start);
}

function x_week_end($date) {
    $ts = strtotime($date);
    $start = (date('w', $ts) == 0) ? $ts : strtotime('last sunday', $ts);
    return date('Y-m-d', strtotime('next saturday', $start));
}

$date = '2013-01-14';
$start = x_week_start($date);
$end = x_week_end($date);
$inquiry_date = date('Y-m-d', $data->field_field_inquiry_date[0]['raw']['value']);

if ($inquiry_date <= $start) {return FALSE;}

I should add that the field_inquiry_date field is a unix timestamp.


texts: Hi I have a bunch of items which occur on a given day of the week. So i have a text field called Day, and it's populated by the words 'Monday', 'Tuesday', 'Wednesday' etc. Is there a way to sort this in views that will list items in Weekday order. I can only find options for alphabetical order.


texts:
I need to setup a rule on the drupal commerce with the following condition.

If Authenticated user added an item in cart and they didn't do the checkout for 24 hours, the site needs to shoot an email to the user with the cart content after 24 hours but only once, dont need to spam in every 24 hours.

How to perform this using rules? Any ideas Champs!!

Thanks


texts:
I have to use Solr to improve my customer search engine, on Drupal 7 website.

On the development environment, I've set Tomcat and web server on the same machine and it works, but I did not inject the whole content database. It contains about 25,000 nodes; I'm not sure if I need to deploy the SolR instance (Tomcat + Solr + configs) on a separated server, or if this won't be useful.


texts:
How can use a CCK file field for uploading a file to another server?

Without leaving the Drupal site, the end users click on the file field's "Browse" button.
They browse for a file on is local computer.
They click on the "Upload" button.
The file is uploading to a remote server.


texts:
We have an existing application with users and we would like to get our user base to accept the terms and conditions. In this regard I did some research and see that legal module comes the closest to desired functionality however there is one concern:

By default the legal module only shows up on login when a user has accepted terms and conditions on registration and only if the terms have changed. What we want to do is to get every user to see that upon login until they accept them.

I looked at the module code and see there is a hook_login function. No matter what I do, this function does not get called. I have tried to backtrace the login system and find out that certain modules do get their hook user login called but some do not. Legal module would be one of them. Any thoughts on how to trouble shoot this further?

The hook is as follows:

function legal_user_login(&$edit, $account) {
  echo "Legal module hook login called"; <--- never see this
  exit; <-- does not get called

  global $user;
  global $language;

  if ($user->uid == 1) {
    return;
  }

  // Get last accepted version for this account
  $legal_account = legal_get_accept($user->uid);

  // If no version has been accepted yet, get version with current language revision.
  if (empty($legal_account['version'])) {
    $conditions = legal_get_conditions($language->language);
    // No conditions set yet.
    if (empty($conditions['conditions'])) {
      return;
    }
  }
  // Get version / revision of last accepted language.
  else {
    $conditions = legal_get_conditions($legal_account['language']);
    // No conditions set yet.
    if (empty($conditions['conditions'])) {
      return;
    }

    // Check latest version of T&C has been accepted.
    $accepted = legal_version_check($user->uid, $conditions['version'], $conditions['revision'], $legal_account);

    if ($accepted) {
      return;
    }
  }

  $uid = $user->uid;

  // Log the user out and regenerate the Drupal session.
  module_invoke_all('user_logout', $user);
  drupal_session_regenerate();

  // We have to use $GLOBALS to unset a global variable.
  $user = drupal_anonymous_user();

  $query = NULL;

  // Deal with destination from password reset one time login link,
  // by creating a new one time login link and setting it as the destination
  // after the T&Cs have been accepted.
  if (arg(0) == 'user' && arg(1) == 'reset') {
    $token = drupal_hash_base64(drupal_random_bytes(55));
    // This is a new, anonymous-user session.
    $_SESSION['pass_reset_' . $uid] = $token;
    $query = array('destination' => "user/$uid/edit?pass-reset-token=$token");
  }

  if (!empty($_REQUEST['destination'])) {
    $query = array('destination' => $_REQUEST['destination']);
  }

  unset($_GET['destination']);

  $result    = db_select('users', 'u')
    ->fields('u')
    ->condition('uid', $uid)
    ->range(0, 1)
    ->execute()
    ->fetchAllAssoc('uid');
  $signatory = array_pop($result);

  drupal_goto('legal_accept/' . $signatory->uid . '/' . md5($signatory->name . $signatory->pass . $signatory->login), array('query' => $query));
}


texts: Link to send private message to current user in the node (author of the content)?

texts:
Is it possible to create a link to send private message to CURRENT USER in the node (to the author of the node content to be more precise). I'm using the Privatemsg module.
I was trying to do this with the Display suite dynamic fields, but I am not able.

I found that the Privatemsg module comes with an option to "Display link on the selected content types. So, I have the "contact current member link" right in the content type, but it shows only for logged in users.

Is there any configuration or hook that I can implement to show the same link to anonymous user?

This is the code that shows the link.

function privatemsg_node_view($node, $view_mode) {
  $types = array_filter(variable_get('privatemsg_link_node_types', array()));
  $url = privatemsg_get_link(user_load($node->uid));
  if (in_array($node->type, $types) && !empty($url) && ($view_mode == 'full' || (variable_get('privatemsg_display_on_teaser', 1) && $view_mode == 'teaser'))) {
    $node->content['links']['#links']['privatemsg_link'] = array(
      'title' => t('Contact member'),
      'href' => $url . '/' . t('Message regarding @node', array('@node' => $node->title)),
      'query' => drupal_get_destination(),
      'attributes' => array('class' => 'button radius privatemsg-send-link privatemsg-send-link-node'),
    );
  }
}

To make it clearer, I don't want anonymous user to send messages. What I want is just a link to log in for anonymous users. Expressing it with pseudo-code...

global $user;

if (isset($user->roles[1])) {
  // Do not show button to Anonymous user and show something else or a button to log in (THE CODE FOR LOG IN)
  echo "something else";
}
else {
  // Show button to logged in user (the code of "Send author a message" button)
}


texts:
I am trying to add this simple script to my block

<script>
    const config = {
      sourceAssetAddress: null,
      sourceAmountDecimal: null,
      destinationAssetAddress: null,
      destinationAmountDecimal: null,
      apiKey: null,
      partnerContractAddress: null,
    };
    const nodeId = "totle-widget";
    !function(){const t=document.createElement("script");t.type="text/javascript";const e=()=>{TotleWidget.default.run(config,document.getElementById(nodeId))};t.readyState?t.onreadystatechange=function(){"loaded"!=t.readyState&&"complete"!=t.readyState||(t.onreadystatechange=null,e())}:t.onload=function(){e()},t.src="https://widget.totle.com/latest/dist.js",document.getElementsByTagName("head")[0].appendChild(t)}();
</script>

Problem I have is that I tried to add it as library like this

(function ($) {

    'use strict';

    /**
     * Attaches the behavior to bootstrap carousel view.
     */
    Drupal.behaviors.totle_widget = {
      attach: function (context, settings) {

        const config = {
            sourceAssetAddress: null,
            sourceAmountDecimal: null,
            destinationAssetAddress: null,
            destinationAmountDecimal: null,
            apiKey: null,
            partnerContractAddress: null,
          };
          const nodeId = 'totle-widget';
          !function(){const t=document.createElement("script");t.type="text/javascript";const e=()=>{TotleWidget.default.run(config,document.getElementById(nodeId))};t.readyState?t.onreadystatechange=function(){"loaded"!=t.readyState&&"complete"!=t.readyState||(t.onreadystatechange=null,e())}:t.onload=function(){e()},t.src="https://widget.totle.com/latest/dist.js",document.getElementsByTagName("head")[0].appendChild(t)}();
}}}(jQuery));

and somehow script goes beserk after this, loads many times and finaly breaks. It is attached to block in build and should be fine.

$build['#attached'] = array('library' => array('exch/totle'));

So I am not really sure what is wrong here. All I want to is to add this script somewhere in body of my html. Like when I add it directly into html.html.twig template of my theme and it works, but ofcourse I want to do it more in drupal way. What is wrong, how should I add this script to my library?


texts: How to get/access field values while inside hook_block_view?

texts:
I want to access the values of my field inside hook_block_view().

I tried with field_get_items(), and field_view_field() with no luck.

By the way the block is showing in a page. Is there a way to get the values set in the content type field settings?


texts: User subscriptions using Webform and Rules

texts: I set up a webform which is displayed as a block on a large number of nodes. The webform asks the user if they would like to subscribe to certain node updates - when a certain field changes value and when a new file is uploaded to another field. I therefore have two checkboxes which the user can check, but my problem is - what next? I can fetch the user email, node id and node title via the webform, but what to do with them? How to sort the users based on what they checked? How to display that on their profiles? Should I assign different roles to them? I would then need a role for every node x 2, which seems like overkill. I did quite a lot of googling, MailChimp seems to have many useful features... Any ideas?


texts: Error on saving node with custom entity validation constraint

texts:
I am testing how to add a custom constraint to a Drupal 8 (node) entity.
I have a fresh D8 site with a content type "Product" and a field "field_stock_level" of type Number (integer).

I created a module with the following code:
entity_validation.module:

/**
 * Implements hook_entity_bundle_field_info_alter().
 */
function entity_validation_entity_bundle_field_info_alter(&$fields,\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
  if ($entity_type->id() == 'node') {
    switch ($bundle) {
      case 'product':
        $fields['field_stock_level']->addConstraint('EvenNumber', []);
        break;
    }
  }
}

EvenNumberConstraint.php:

<?php
// Note: file is saved in location: modules/custom/entity_validation/src/Plugin/Validation/Constraint/EvenNumberConstraint.php
/**
 * @file
 * Contains \Drupal\entity_validation\Plugin\Validation\Constraint\EvenNumberConstraint.
 */
namespace Drupal\entity_validation\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraint;
/**
 * Checks that a given number is even.
 *
 * @Constraint(
 *   id = "EvenNumber",
 *   label = @Translation("Even Number", context = "Validation"),
 * )
 */
class EvenNumberConstraint extends Constraint {

  public $noEvenNumberMessage = 'The entered number must be even.';
}

EvenNumberConstraintValidator.php:

<?php
// Note: file is saved in location: modules/custom/entity_validation/src/Plugin/Validation/Constraint/EvenNumberConstraintValidator.php
/**
 * @file
 * Contains \Drupal\entity_validation\Plugin\Validation\Constraint\EvenNumberConstraintValidator.
 */
namespace Drupal\entity_validation\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
/**
 * Validates the EvenNumber constraint.
 */
class EvenNumberConstraintValidator extends ConstraintValidator {
  /**
   * {@inheritdoc}
   */
  public function validate($field, Constraint $constraint) {
    $value = $field->value;
    if (!isset($value)) {
      return NULL;
    }
    // Verify that given value is even.
    if ($value % 2 != 0) {
      $this->context->addViolation($constraint->noEvenNumberMessage);
    }
  }
}

The validation runs, and the code adds the violation.
However on saving the node, I get the following error:

  Recoverable fatal error: Argument 1 passed to Drupal\Core\Form\FormState::setError() must be of the type array, null given, called in core/lib/Drupal/Core/Field/WidgetBase.php on line 448 and defined in Drupal\Core\Form\FormState->setError() (line 1157 of core/lib/Drupal/Core/Form/FormState.php).

Anyone knows what's going on? I can't seem to figure it out...


texts: How to change drupal commerce status message?

texts:
I have created a custom cart and checkout. When product is added to cart, drupal displays a message "The product XYZ has been added to your cart" through rules which links to default cart. How can I change the message to link to my custom cart?
Note: I checked the other questions but none is related to changing links to carts or DC etc.

Thanks in advance.


texts:
In the admin area, to create a custom block, I go to:

Structure, Block layout, + Add custom block.

Once I create the custom block in the UI, I see a textarea field called "Body" where I can enter content.

How can I dynamically render the node author's name and profile picture in my custom block. I know I can type it in, but I would like to be able to insert some code (PHP, Twig or token) so that it pull's the author's name and profile image dynamically and prints it on the block. I do not want to use a views block, but a custom block instead.


texts: Pull Profile2 Fields into Product Display node based on selection of Profile Owner

texts: I want to select an artist using a selector and have several fields from their profile2 profile ( main profile ) appear in the product creation form. I can select the artist now, but I need to have about 9 fields reference the selection and pull their info from the same profile.


texts: How to implement search on multiple fields limited to one content type in drupal 7

texts:
I've created a new content type which has several fields (some of them are custom fields I created myself). Now I need to implement a search function on each of those fields.

This means that if I have these fields:

VideoCV (video field)
Occupation (text field)
Driving licence (select lists)
Region of birth (taxonomy term)

I need a search module with those four fields, so that if you search for occupation "engineer" it searches only data inserted in that specific field.

What do I need to do? What additional modules should I install? What should i do with my custom fields?


texts: CKEditor "Source" button does not brings back the full html

texts:
I have written a full html code

&nbsp;

But when I edit the content and click on the "Source" button provided in the CKEditor toolbar. nothing is showing up

In Advanced content filter I have given in Extra allowed content

p(*)[*]{*};div(*)[*]{*};li(*)[*]{*};ul(*)[*]{*}

In Custom JavaScript configuration I have given

config.allowedContent = true;


texts:
I have a View that displays four types of field (field_ba_before, field_photo_gallery, field_body_image, field_image_position).

In my views-view-fields.tpl.php file, I have created a variable called $class. I want the variable of $class to change according to the values of the four fields.

Not every Views row result will use all of the fields, so in my code, I have used IF statements to check if the field exists.

This is my code:

<?php if(($fields['field_ba_before']-> content || $fields['field_photo_gallery']-> content)): ?>
<?php $class = "content-aside-layered"; ?>
<?php else: ?>
<?php if (($fields['field_body_image']-> content)): ?>

    <?php if (($fields['field_image_position']-> content) == 'image_position_right'): ?>
    <?php $class = "content-aside"; ?>
    <?php endif; ?>

    <?php if (($fields['field_image_position']-> content) == 'image_position_left'): ?>
    <?php $class = "aside-content"; ?>
    <?php endif; ?>

    <?php if (($fields['field_image_position']-> content) == 'image_position_bottom'): ?>
    <?php $class = "content-aside-layered"; ?>
    <?php endif; ?>

    <?php if (($fields['field_image_position']-> content) == 'image_position_default'): ?>
    <?php $class = theme_get_setting('body_image_position'); ?>
    <?php endif; ?>

<?php endif; ?>
<?php endif; ?>

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

I am not sure why it is not working. Is there a special way of testing the values of Views fields? Thanks for any help that can be offered!


texts: How can open add content form in modal form module

texts:
I want to load content form (example article content type ) in modal.

As Modal module allow to open forms in modal, but by default it given this feature to some of the form. My question is how can I use this module to add other content type forms.

How can I add content in modal form ?


texts: Ctools custom relationship plugin (context)

texts:
I am trying to create a custom ctools relationship plugin

Create a custom context based on another context
With the data from the required context I want to provide some tokens

When I create a custom context relationship using the example in ctools_plugin_example/relationships/relcontext_from_simplecontext.inc
the context gets created but there is only the main parent keyword "Keyword: %relcontext_2" without any tokens to use.

In the simplecontext example tokens are created by
'convert list' => 'simplecontext_convert_list'
'convert' => 'simplecontext_convert'.

However in the relationship example the comments simply says:

// Create the new context from some element of the parent context.
// In this case, we'll pass in the whole context so it can be used to
// create the relcontext.

So how does this work ?

I would like to add a required context of a taxonomy term and then be provided with tokens
Adding the 'convert list' functions to the relationship example doesn't seem to work.

<?php

 /**
    * @file
    *
    * Sample relationship plugin.
    *
    * We take a simplecontext, look in it for what we need to make a relcontext,    and make it.
    * In the real world, this might be getting a taxonomy id from a node, for example.
    */

    /**
    * Plugins are described by creating a $plugin array which will be used
    * by the system that includes this file.
    */
$plugin = array(
  'title' => t("Custom context"),
  'keyword' => 'multi_term',
  'description' => t('Adds a relcontext from existing term.'),
  'required context' => new ctools_context_required(t('Taxonomy Term'), 'taxonomy_term'),
  'context' => 'ctools_relcontext_from_term_context',
  'settings form' => 'ctools_relcontext_from_term_settings_form',
  // Provides a list of items which are exposed as keywords.
  'convert list' => 'relcontext_from_term_convert_list',   // You need something like this to
  // Convert keywords into data.
  'convert' => 'relcontext_from_term_convert',
);

/**
 * Return a new context based on an existing context.
 */
function ctools_relcontext_from_term_context($context = NULL, $conf) {

  //break it into a smaller chunk
  $data = $context->data;

  //Loop through the data to get the taxonomy id's
  foreach($data->field_MY_MULTI_TERM_REF_FIELD['und'] as $holder) {
     foreach($holder as $tid) {
       $tids .= '+'.$tid;
     }
  }

  $tids = substr($tids,1);

  // If unset it wants a generic, unfilled context, which is just NULL.
  if (empty($context->data)) {
    return ctools_context_create_empty('multi_term', NULL);
  }

  // NOT SURE HOW TO PROPERLY ADD THE DATA
  $context->data->multi_term = $tids;
  // ALSO NOT SURE HOW TO BUILD THE DATA TO POPULATE KEYWORD TOKENS

  // You should do error-checking here.

  // Create the new context from some element of the parent context.
  // In this case, we'll pass in the whole context so it can be used to
  // create the relcontext.

  return ctools_context_create('multi_term', $context);
}

/**
 * Settings form for the relationship.
 */
function ctools_relcontext_from_term_settings_form($conf) {
  // We won't configure it in this case.
  return array();
}

// COPY FROM SIMPLE CONTEXT EXAMPLE
function relcontext_from_term_convert_list() {
  // NEED TO CREATE THE ITEM 1... BEFORE
  return array(
    'item1' => t('Item1'),
    'item2' => t('Item2'),
    'description' => t('Description'),
  );
}

// COPY FROM SIMPLE CONTEXT EXAMPLE
function relcontext_from_term_convert($context, $type) {
  switch ($type) {
    case 'item1':
      return $context->data->item1;
    case 'item2':
      return $context->data->item2;
    case 'description':
      return $context->data->description;
  }
}


texts: How do I update customers cart prices and add discount and then let them checkout?

texts:
I'm using Drupal 7 Commerce and Commerce discount, amongst many others.

So the use case is this. We often get enquiries for bulk orders containing many products. We want our customer to go to the website and add what they want into their cart. As admin I want to open that unpaid cart, edit product prices and apply a Fixed Price Discount. Then when the customer refreshes their cart they will see our amendments and continue with payment. Is this possible? Am I missing something obvious?

At present I can edit a order that is in the cart but when the customer refreshes their cart the order is reverted back to prior my changes. I can't edit product prices at all whilst the order isn't completed. Once in Completed status, I can tweak product prices and add the discount.

To get the Fixed price discount feature to work I had to switch from the Line Item Manager widget over to Multiple Inline Entity References. For the line items field on orders that is. Before that I couldn't use the Fixed price discount feature at all.

Any help would be greatly appreciated. I must be performing the wrong searches or something.


texts: In the Counter module the Visitors "This Year" count is decreasing. How can I get it to increase instead?

texts: The Visitors "This Year" count decreases in number in the D8 Counter module while the "Hits" and "Visits" increase as normal. For example, one afternoon the "This Year" count was 329,546. The next morning it was 328,149. The third day is was 327,138. The "Visits" and "Hits" only increase on the average of 150 per week. The "This Year" is decreasing more than a thousand by the day(????) What's going on? Any help would be appreciated.


texts: How to determine if Varnish/Pressflow is caching content in a useful way?

texts:
I recently converted one of my D6 sites to Varnish/Pressflow and saw a very modest improvement in average load speed (from ~550ms before to ~450ms now). But, I also noticed that the initial load time for the first load in a round of tests were consistently much higher --- around 1000ms. They quickly fall down to ~450ms during subsequent reloads during the same test.

This makes me think that I've configured something incorrectly, and Varnish isn't serving from the cache until after the (anonymous) user has already visited the page in question. Perhaps the session IDs are causing each session to be cached independently from eachother (though I understand that shouldn't happen for anonymous users under Pressflow).

The X-Varnish headers appear in both the initial page load, and subsequent loads, so I know the content is at least getting passed through Varnish.

Is there a way to get details about part of the Varnish cache is serving a particular page (e.g. when the cached page was created)? I've tried looking at the logs generated by varnishlog, but apart from various apearances of "X-Drupal-Cache: HIT" I'm not sure what to look for.


texts: Logo does not display after uploading it

texts:
After I selected the logo in the theme settings (Appearance > Settings > Choose File), I clicked 'Save Configuration'. It says 'custom logo path is invalid'. I did not have write permission for the default folder under sites. After i gave write permission to the default directory, I did not get the above error.

Now, I am able to upload the logo  but I am not able to see the uploaded logo on my page. Do you know why my logo does not display on my page after I uploading it successfully?


texts: Get enitity ID after programatically creating one

texts:
I have a the following code:

// Create an Entity with wrapper
  $node = entity_create('node', array('type' => 'person'));
  $entity = entity_metadata_wrapper('node',  $node);

  // Add a node title
  $entity->title = $person['name'];

  // Add the address information
  $entity->field_person_address->thoroughfare = $person['address'];
  $entity->field_person_address->locality = $person['city'];
  $entity->field_person_address->administrative_area = $person['state'];
  $entity->field_person_address->postal_code = $person['postalcode'];
  $entity->field_person_address->country = $person['country'];

  // Save the entity
  $entity->save();

The data is saved in the DB perfeclty, but I need to get the entity ID of the new save node.

How do I do that?


texts: Save selected values from a checkbox into a field

texts:
I've the next form.

  $query = "SELECT name, tid FROM taxonomy_term_data WHERE vid=2 AND language = '$language_url';";
  $result = db_query($query);
  foreach ($result as $row2) {
     $options2[$row2->tid] = t($row2->name);
  }
  $form['group_config']['municipios'] = array(
     '#type' => 'checkboxes',
     '#title' => t('Municipios'),
     '#options' => $options2,
     '#required' => TRUE,
  );

I do a query to take the differents taxonomy terms that I have.

I don't know how to obtain the values that the user has selected and save into a field.

I've done the next code but It dosn't work.

   function anuncio_datos_usuario(&$form_state,$values){
        $node = new stdClass();
        $node->title = $values['titulo'];
    $node->type = $type;
    node_object_prepare($node);
    $node->language = $values['idioma'];
    $node->uid = $userid;
    $node->status = 0; //(1 or 0): published or not
    $node->promote = 0; //(1 or 0): promoted to front page
    $node->sticky = 0;
        if(count($values['municipios']))
        foreach($values['municipios'] as $municipio){
            if($municipio!=0){
                $node->field_municipio[LANGUAGE_NONE][]['tid']= $municipio;
            }

        }
    $node = node_submit($node); // Prepare node for saving
    node_save($node);

How can I save all the selected values into the field?

Thank you.


texts:
After installing tons of modules like guestbook, subscriptions etc. It also added tons of settings on user/$uid/edit page. How can I disable or rearrange them?

I guess theme_fieldset() would help me, but I have no idea how to use it correctly. And where to print_r($form) and in which template?


texts: IPGV&M, how do I get the geocoder to prefer locations 'near me'

texts:
For example, if the map is centred on Sydney and people enter 2000 in the 'move to' box it sends me to Portland rather than Sydney CBD which also has a postcode of 2000.

The regionbound description is an accurate description of my setup, except that I am not using regionbound or any special clustering rules.

The description has an 'editable box' '...replace with suburb... Australia' which seems like a clunky way to do it. I'd like a placeholder rather than text that has to be deleted if possible.


texts: SEO View Page using OG delta or Url as Contextual Filter

texts:
I've been trying to use Delta of OG and/or Group Url to use it as a Contextual Filter in a Page View. I want to show the content of the group filtered for the corresponding group. If' now my Group Urls are like "grupo/group-name", I'd like to filter that Groups posts like "posts/grupo/group-name", but all I can do is filter by Gid, like "posts/grupo/1", which is obviously not SEO.

Is there a relation or anything I can use to achieve this? I saw I could print out the url of the Group node as a Field in a View, which is what I'd need for "posts/grupo/group-name", because the url of the node I print is "grupo/group-name". Anyway, there's no Contextual Filter I can apply with that option.

Any thoughts?

THANKS!!!!


texts: Change order of markup for exposed views filter

texts:
I have a search box on my homepage, and to style it correctly I need the button to come before the text box in the markup. The current block code looks like the following.

<form action="/drupal-7.22/search" method="get" id="views-exposed-form-commerce-search-page" accept-charset="UTF-8">

            Search for products

 <input type="text" id="edit-search-api-views-fulltext" name="search_api_views_fulltext" value="" size="30" maxlength="128" class="form-text required error">

      <input type="submit" id="edit-submit-commerce-search" name="" value="Go!" class="form-submit">

</form>

I've looked at hook_form_alter() and a few template files, but I think that's the wrong way to do it and I'm far from an expert.

I wouldn't mind being able to clean up that tangle of divs too!


texts:
I am trying to set up a sale price on certain products on a drupal site, however from the project page of commerce_saleprice there is this patch https://drupal.org/files/commerce-views_precalculated_price-1020050-5.patch that should be applied but am stack because i dont know to which module this has to be applied as i tried applying it to commerce_saleprice and it fails.

My requirement is to put some products on sale and then call them in a view... any insight on this, i already have price savings formatters installed.


texts: Create images defined by image styles on node save

texts:
In Drupal 7 I wish to create several images defined by image styles when saving a node. There is only one image field, and it is just several styles of that image that I need to generate.

None of these images are displayed when viewing the node, they will be accessed through XML and Services.

I think mabye the hook_preprocess_HOOK and theme_image_style can be used as pointed out in this question: Multiple image styles. Is this correct? And if so, can anyone point me to some examples where this is done? In the link above, images are echo'ed out, but is this how it should be done when saving a node?


texts: Views pagination based on taxonomy terms

texts:
I have an archive Views page in Drupal 7 that is paginated after 10 items, themselves grouped and sorted by a taxonomy term ("issue date").

I've been asked whether it's at all possible to make the pager more descriptive based on the taxonomy vocab — i.e., instead of it just being "Go to Page 2", it's "Go to issues 2012-07-06 to 2012-06-29".

Any idea how I'd do that? Thanks!


texts: Can I write MySQL settings in drupal settings.php file?

texts:
I am using Drupal 7 and i am getting MySQL server has gone away error in my current site.
By doing Google i figured out that i need to increase some of the parameters of my.ini file

key_buffer
max_allowed_packet
table_cache
sort_buffer_size

Is there any way that I can write this in Drupals settings.php?


texts: Multisite cannot find module in sites/default

texts:
I haven recently set up a multisite setup with Live, staging and tag as the domina/subdomains used by the code

in the sites directory I have the modules set up like so:

sites/all/modules/<modules shared by ALL sites>
sites/default/modules/<modules ONLY used by default>
sites/tag.example.com/modules/<modules ONLY used by tag>
sites/staging.example.com/modules/<modules ONLY used by staging>

in the default, staging and tag modules directory are independent copies of modules that I am developing.

However when I add new urls to hook_menu() in any module in staging it is not picked up at all, only when the function is populated to sites/all

further to this, the modules disappear from the admin/modules page

on top of this there is this next issue.

If I place My_Module into the default and staging folder there are times that it either says that a function name cannot be found (when it is blatantly using the module) OR even worse is when it says I cannot re-declare a given function name

So can anyone point out if I am doing something wrong?

Am I putting the modules in the correct places because when I have EXACT duplicates of a module in separate site folders (staging and default but not all)  I am able to edit the content and see that the content has been edited but not add new urls/functions that get picked up.

And YES I am flushing all caches when uploading new hook_menu() items and function changes etc

Any Help is appreciated.

Thanks, Jim.


texts: Uploading via default image on Articles not working

texts:
I am trying to upload images on the default Article node type on D7.

The upload works and the image is confirmed via Linux on the file system.

However, the icon of the uploaded image is a broken link image and the same when viewing the page.

I get the following error message:

Forbidden

You don't have permission to access /RT/sites/default/files/field/image/prayer.jpg on this server.

Please help.

UPDATE:

I have been looking into permissions as a solution but with no luck. I went as far as assigning 777 permissions to the files folder and all it's sub-folders and even the target image.

Strangely, I tried uploading an image to an article node on a different website running on the same server which worked. I installed a fresh website and tried it there and that also worked.

Basically, it seems one website among three all on the same server is not responding correctly when I attempt to upload images.


texts: Views exposed filter to search multiple fields

texts:
To my knowledge there hasn't been an option in drupal 7 to create a single exposed filter in a view which searches multiple fields, while in previous versions there existed modules to do just that.

Using the or operators is fine but then you get multiple fields in the form.

Add Global: Populate filters and you can have a single field but then the view never shows anything.

Is there any way or module that will make this work?

Edit: What I didn't notice was the field operators. For some reason the default operator for text fields in views is =, while a proper search function needs contains or has word. I've been looking for the reason I couldn't get it to work for almost 6 months now. Wow. What a pain. /facepalm


texts:
I want to create simple actions that will change the field_support_status field value to 1 or 0. I enabled the "Actions" module and created a custom module with my actions, but after the module is installed the actions do not appear.

In my module, I created files with the following structure:

/src/Plugins/Action/SupportStatusYes.php

<?php
namespace Drupal\support_action\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
/**
 * Change support status on yes.
 *
 * @Action(
 *   id = "support_status_yes",
 *   label = @Translation("Change support status on yes"),
 *   type = "node"
 * )
 */
class SupportStatusYes extends ActionBase {

  /**
   * {@inheritdoc}
   */
  public function execute($entity = NULL) {
    /** @var \Drupal\node\NodeInterface $node */
    if ($entity->hasField('field_support_status')) {
      $entity->field_support_status->value = 1;
      $entity->save();
    }

  }

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    /** @var \Drupal\node\NodeInterface $object */
    $result = $object->access('update', $account, TRUE)
      ->andIf($object->field_support_status->access('edit', $account, TRUE));

    return $return_as_object ? $result : $result->isAllowed();
  }

}

/src/Plugins/Action/SupportStatusNo.php

<?php
namespace Drupal\support_action\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
/**
 * Change support status on no.
 *
 * @Action(
 *   id = "support_status_no",
 *   label = @Translation("Change support status on no"),
 *   type = "node"
 * )
 */
class SupportStatusNo extends ActionBase {

  /**
   * {@inheritdoc}
   */
  public function execute($entity = NULL) {
    /** @var \Drupal\node\NodeInterface $node */
    if ($entity->hasField('field_support_status')) {
      $entity->field_support_status->value = 0;
      $entity->save();
    }

  }

  /**
   * {@inheritdoc}
   */
  public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
    /** @var \Drupal\node\NodeInterface $object */
    $result = $object->access('update', $account, TRUE)
      ->andIf($object->field_support_status->access('edit', $account, TRUE));

    return $return_as_object ? $result : $result->isAllowed();
  }

}

/config/install/system.action.support_status_no.yml

langcode: en
status: true
dependencies:
  module:
    - node
id: support_status_no
label: 'Change support status on no'
type: node
plugin: support_status_no
configuration: {  }

/config/install/system.action.support_status_yes.yml

langcode: en
status: true
dependencies:
  module:
    - node
id: support_status_yes
label: 'Change support status on yes'
type: node
plugin: support_status_yes
configuration: {  }

/config/schema/support_action.schema.yml

action.configuration.support_status_yes:
  type: action_configuration_default
  label: 'Change support status on yes'

action.configuration.support_status_no:
  type: action_configuration_default
  label: 'Change support status on no'

Tell me please what am I doing wrong?


texts: Permissions for adding bundles to custom entities

texts:
I've made some custom entities using the Entity API and I would like to give some users the ability to add bundles to them.

However it seems that in order to add bundles they have to have the "Administer site configuration" permission. I am a bit concerned about giving users that, especially as we might be doing a multisite system where different organisations will own different sites. I'm worried that they might be able configure directories and file paths and end up getting access to things on the other sites.

There is a special permission for creating content types, so I wonder whether there could also be one for creating bundles of other kinds of entities. It seems an oversight that there is not.