texts: Problem with adding checkbox to a view of flags with webform view

texts:
So, I've been trying to implement a 'sample request' type webform using Flag, Webform, and Webform Views. The idea is to have a webform with a select list made from a view of Flags as implemented here through a custom moduleProgrammatic Sample Request, Drupal Steve.

The issue I'm having is that I can't seem to get a checkbox to show up in the view. I have followed the instructions at the webform views documentationWebform Views Docs by creating a boolean field with a checkbox widget. I'm Flagging Commerce products.  I have even tried to add a boolean on Flags and add that into the view, but that didn't work either.  Not sure is this is a Flags, Commerce, or Webform Views issue, but I wanted to report this here and see if anyone had any ideas.


texts:
-Drupal 7.37 & Omega4-Subtheme

-Windows7 HP & Toshiba Laptop

-Acquia-DevDesktop WAMP-Stack

-Latest Wysiwyg, CKEditor & Media_Module & Media_Oembed

Now I have tried everything and nothing allows a Facebook Video to Embed.

I have tried using the Facebook-URI/Embed-Code in the Media_Module-Media-Browser as well as dropping the Facebook-Embed-Code (using cut-and-paste) in the text-area.  The Facebook-Embed-Code that Facebook gives you, BTW seems strange to me.

Oembed (not the Media_Oembed Module) did not work at all.
Tried using another Wysiwyg-Rich-Text-Editor, besides CKEditor, because CKEditor strips out code and that switch did not help make the Videos embed.
Tried editing the CKEditor Advanced-Content-Filter to stop it from rewiring any code and that did not help.
The Video-Lightbox Software application seems to refuse the Facebook URI's also.
Media_Oembed also fails to help Media_Module to recognize Facebook-Embeds or URI's.
When I just cut-and-paste the Facebook-Embed-Code directly into a basic HTML-Document outside of Drupal (and even outside of a WAMP-Stack), this also does not work.  Viewing the source-code in FireFox, again I see some of the Facebook-Embed-Code is missing, having been stripped out by something.  What? FireFox?  HTML5?  This is the most puzzling.  Maybe the WAMP-Stack is necessary for embeds, but the link works.
Something seems to be removing part of the Code or else Facebook is using bad code inadvertently, being unaware of some configuration in the outside world.
Basically the URI's just deliver a red-reject-box from the Media_Module-Browser or else they deliver an iFrame or Flash that is dead in the water. Direct cut-and-pastes deliver just direct unprocessed raw code on output or else just, oddly, a link to the Facebook-Page that shows the name of the Video's owner and nothing more.
Any thought from anyone?  I am just really interested if anyone out there is embedding Facebook-Videos in ANY kind of way and if so, how?


texts:
I'm trying to speed up my test.
I have to use simpletest_clone.
I've read something like "copy the database to memory" but i did some research and didn't found how.
Aaand if i want to do more than one test with the same database there is somehow a thing that let you use the same database cloned for the first case i tested to be still loaded to run the next test case?
because if i want to run 4 or 5 test case using simpletest_clone it may take years if i let it clone and drop the database for every case


texts: hook_nodeapi called multiple times with op='update'

texts:
I am using the media_mover module.  I added some debug code to media_mover's hook_nodeapi:

function media_mover_api_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  dsm ("entering hook_nodeapi.  op=$op");
  switch ($op) {
    ...
    case 'update':
       ...
       break;
  }
}

When the user edits and saves a node, hook_nodeapi is getting called twice with $op='update'.  Anyone know why this might be?

If media_mover calls node_save during the process of saving the updated node, might that cause hook_nodeapi to be called multiple times with $op='update'?

(I am using Drupal-6.x)


texts:
I'm writing a module and it's form aspects are fine, including fetching data from my database. I use entity metadata wrapper to fetch the field data from my database. I'm using data from a field collection in entityform submissions. I use a URL/page argument to select the specific entityform submission I'm pulling from.

The issue is when adding ajax functionality to any textfield it gives a 500 error. Doesn't matter what (or anything) I have in the AJAX callback function, it bombs. The error messages don't give me enough info, as far as I can tell, other than it seems to be related to the page argument that specifies the individual entityform ID. BTW, PHP memory is 256 (I mention this as the most common reported cause of a 500 error seems to be low PHP memory - don't think that's my issue).

Here are the error messages:

An AJAX HTTP error occured. HTTP Result Code: 500. EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. Value at entityform(): ajax. in EntityDrupalWrapper->set() (line 756 of /home/mysite/mysite.dreamhosters.com/sites/all/modules/entity/includes/entity.wrapper.inc).

Strict warning: Only variables should be passed by reference in investment_lineitems_form() (line 48 of /home/mysite/mysite.dreamhosters.com/sites/all/modules/investment_lineitems/investment_lineitems.module).

Here's the code:

/**
 * Implements hook_form()
 */
 function investment_lineitems_form($form, &$form_state) {

    $itemcounter = 0;

    $entityform = array_pop(arg());   // ****  THIS IS LINE 48

    $wrapper = entity_metadata_wrapper('entityform', $entityform);

    foreach ($wrapper->field_inv_account_details as $field_collection_wrapper) {
      $field_your_percent_a = $field_collection_wrapper->field_inv_your_percent_split_a->value();
      $itemcounter++;
      if (!empty($field_item_value)){

    $form['edit_your_percent_amount_'.$itemcounter] = array(
        '#type' => 'textfield', //you can find a list of available types in the form api
        //'#title' => 'Item Value '.$itemcounter, //Form the field label
        '#size' => 5,
        '#maxlength' => 5,
        '#value'=>$field_your_percent_a,
        '#required' => FALSE, //make this field required
        '#ajax' => array(
            'callback' => 'ajax_alert_callback',
        ),
        //'#weight' => 5,
           );
               }
    }

  $form['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Save Changes'),
    '#weight' => 15,
  );

  return $form;
}

 /**
 * Callback for 'alert'.    USE THIS FOR TESTING AND DEBUGGING
 *
 * @see ajax_command_alert()
 */
function ajax_alert_callback($form, $form_state) {
  //$commands = array();
  //$commands[] = dsm($form_state['triggering_element']); //ajax_command_alert("Alert requested");
  //return array('#type' => 'ajax', '#commands' => $commands);

}

Note: My callback function shows commented lines - attempts to debug the issue. Even without anything in that function I get the error, so it doesn't even seem to get that far.

Any recommendations or suggestions are very welcome.


texts: Adding a field with an automatic link in a content type from entity registration module

texts:
I'm using Drupal to create a website which allows an "employer_role" user to create a "Post Job" content type that has a field type of registration from entity registration module and inside that registration should contains information about an "applicant_role" user EX: Name, Job, Letter, and a automatic link generator where it will link it to the "Applicant's" resume content.

I'm quite new to Drupal and the only thing I can manage is a textbox where the applicant should mannually link his resume content path, which I also don't want the applicant's to put a link from another website.

Any suggestions to help me?

Content type: "Post Job"

  fields:

  Title : text

  company name: text

  job title : text

  body: text //job description

  register: registration // apply form

registration form fields

  Applicant Name: Text

  Applicant Job: Text

  letter: long text

  my profile/resume: auto link field which will direct to the
  applicant's resume content


texts: Should I use content-types or database abstraction layer?

texts:
I am building an admin site for my brother's property management company. The design seems pretty straight forward.

I need a database with tables to store:

Estates. Each estate has a number or properties (flats or houses). Each property has a number of charges (service charge, water bills, maintenance ect.)

Then I have: Owners. Each Owner must have ONE or MORE properties. Owners make payments. Each payment is allocated to ONE or MORE charges.

From there I add CRUD functionality and the ability to produce reports by estate, property and/or owner.

Being new to Drupal I originally thought that the way to do this is create a content-type for each of the tables (e.g Estate, property, charge, owner, payment) and then use the relations module to enforce any foreign keys and automatic additions and update.

However, I have spent this week reading pro drupal development 7 and now I see  I can build the database using the schema module and add functionality through the database abstraction layer with the functions declared in database.inc.

Does anyone have an opinion on which is the best way forward? Or am I missing the point a bit? Do I use them both?

Thanks for any advice and Merry Christmas (or Happy Holidays, whichever you prefer)


texts: How to download file by clicking on icon in file module?

texts:
I have a File field in drupal 7 (with file module) which I forced with views to display as an icon and name of the file which uploaded. The Name displays as a link (to download file). Now I want to link the icon to the file too. So when users click on the icon they would be available to download file (and I prefer to exclude the name from display).
What should I do now to make the icon as a download link?
Thanks.


texts: I created some fields such as Color called field_color (taxonomy terms) in the product content type but whatever I do, when I create a product and set the field_color, the color name doesn't show up on the product page. I also tried to create fields programmatically with hook_install and hook_schema_alter but to no avail. Maybe I'm doing something wrong as I have never created any fields/schema before.


texts:
I'm using CSE in my drupal website and due to some technique restrictions i couldn't use Solr search.

My news portal gives a " RELATED CONTENT " block to each article using tags similarity but i'm not very satisfied with the result.

I wonder if there's a way to integrate Google Search (like solr module does) to return back (in a view) a list of similar nodes by searching the title for example.


texts:
Seems to be an extremely simple question. But I can't figure it out. In my module's form I need to load form values depend on the value of certain one and rebuild the form using those.

here is the part of the code (form builder):

$namevalue = isset($form_state['values']['name']) ? $form_state['values']['name'] : "";
$form['name'] = array(
    '#type' => 'textfield',
    '#default_value' => $namevalue
);
$form['load_settings'] = array(
    '#type' => 'button',
    '#value' => t('Load my settings'),
    '#ajax' => array(
        'callback' => 'simplenews_mod_load_subscriptions',
    )
);

Here is the callback:

function simplenews_mod_load_subscriptions( $form, &$form_state){
  $form_state['values']['name'] = "loaded value"; // here will be a function which will get the value form DB
  return $form_state;
}

Nothing changes in the $form_state array.
I think I just don't get the basis of ajax in D7 itself... I'd be very appreciated if someone show my the simplest example of how to change a form field value using ajax.

Or alternatively: how do I rebuild form with new values using custom submit callback. Not on validation.

Thank you.


texts: Module Webform won't send email to certain address

texts:
For some reason the normal contact form won't work. It doesn't send any mail to any address I request.
Therefore, I used the module Webform for Drupal 7.

The problem I have is almost the same described in this thread.

However, for me the problem is even when the domain name is the same.  Like user1@domain.com works, but info@domain.com doesn't.

When I do send to a gmail account, there also is no problem.
Basically, the info@domain.com doesn't seem to be 'supported'.
All the other email addresses do work.

The domain-email is hosted by Gmail. (A Google Business account)

What am I missing?


texts:
How can I convert one field from html (generated with CKEdit) to normal plain text?
The HTML is
Line1boldanditalics"Line2" simpleLine3justbold

I have tried:

1)
$title = drupal_html_to_text($title);
$title = str_replace('*', '',$title);
$title = str_replace('/', '',$title);
$title = str_replace("&quot;", "\"",$title);

but I can't really remove the quotes, the last line does not seem to work.

2)  html_entity_decode() instead
then I get all the <p&gt...Line1
3) I tried to parse it myself and remove via str_replace and preg_replace, but that's a bit more complicated.

The html can contain only the following tags: p strong> em

How can I get to
Line1boldanditalics "Line2" simple Line3justbold

Thank you


texts: Loop trough items in view template and access field values?

texts:
Drupal 8
name of twig: views-view-grid--places.html

I'm extremely new to Drupal so bare with me and excuse any incorrect lingo.

I created a content type called places and added 2 fields (body and field_location). title is a default for fields.

In my view twig, how do I get those values in my for loop?

{% for item in items %}

{{ item.title }}

{{ item.field_location }}

{{ item.content }}

{% endfor %}

This only outputs the body. What am I missing?


texts: How to add another navigation bar/block at the top of your site?

texts:
I want to add a custom header/navigation block at the very top of my page like so, it's essentially a menu item. For example, it has two items:
Home and Business. Once clicked it stays highlighted and menu items below it change.

The default is Home, and it has its own header and page underneath.
If a user clicks 'Business', it will load another page with a different header/menu items.

I am wondering: How would I do this in drupal? Would I do it all in the navigation block? Would customization be required and where exactly?
Any advice on how I can approach this best?

For example,
These two menu items will be the top parents of every page.

Home
|
|___menu item/page 1
|   |
|   |__Another page, etc
|___menu item 2/page 2
|___menu item 3/page 3

Business
|
|___a different menu item/page 1
|___a different menu item/page 2
|___a different menu item/page 3


texts: Multi-site - can I route second site to different urls?

texts:
I've got a multi-site Drupal installation with 2 sub-domains pointing to the same Drupal site. Eg: subdomain1.mysite.com and subdomain2.mysite.com

I have a page set up using hook_menu with the path 'site/%'. Eg: subdomain1.mysite.com/site/test

I want all requests to subdomain2.mysite.com/% to point to this page. Eg: subdomain2.mysite.com/test should point to the same page as subdomain1.mysite.com/site/test

How can I do this?


texts: Image style in views field template on image

texts:
I'm struggling with a piece of code in my views field template.

A short overview of the situation:

Node product has a field with filename for an image
Images are added with filezilla in default/files/products

What is the best way to implement image styles on these images.
My code:

<?php
 print theme('image_style', array('style_name' => 'product_overzicht', 'path' => $img_url));
?>

Where $img_url is just a simple variable, like: img_filename.jpg

This doesn't work because the folder of that image style is empty. I know the easy way is to use an image field on my product node but this can't be done here. I use a excel import for all products and the image filename is a column in that excel file. Images are all together in a folder.

Does anybody know a way do this or a good workaround. CSS markup is not good because the image size needs to be as low as possible in the view but on de node details page I would like to show the entire image.

Any tips or advice is welcome!


texts: Problem adding button to custom content type form

texts:
I am trying to add a cancel button to a custom content type form (typename/type/add).
I have looked around and there seems to be two main ways of doing this:

Creating a template file with the name page--node--add--typename.tpl
Implementing the hook_form_alter either in the theme template.tpl.php or in a custom module.

then adding code like

$form['actions']['cancel'] = array(
    '#type'   => 'submit',
    '#value'  => t('Cancel'),
    '#access' => TRUE,
    '#weight' => 55,
    '#submit' => array('cancel_button_form_cancel', 'node_form_submit_build_node'),
    '#limit_validation_errors' => array(),
);

In the first case,  after rendering the form with drupal_render($form) the button is added but only the form is rendered. Main menu and other blocks are not rendered.

However in the second case the button never appears. Even though something like drupal_set_title('Title') does change the title.

Any solution to either issue would be most welcome.

Edit
The first part of this question is now a separate one here.


texts: Why does the files directory ignore system wide umask?

texts:
I have a Debian test system running Nginx and PHP-FPM, and have set a system wide umask of 027 which translates to default permissions of U=RWX G=RX O= for directors and U=RWX G=R O= for new folders and files, respectively.

After running the Drupal installer and reviewing directory structure, I notice that the installer generated files directory has default permissions of U=RWX G=RWX O=RX.  Any files uploaded to this directory also receive similar permissions.  Why is this so?  Is it hard coded into the software to provide such permissions?

It would seem that if any new folders of files created in the files directory will receive hard coded permissions, that you would need to regularly update those permissions to something of your choosing.


texts: Export/Deploy Drupal site/page to static? (no cache)

texts:
I wonder if there is an existing  module that can help in the subject.
I am not looking for a caching module (like Boost or Varnish), but a way to export my whole site (or only certain pages) into static.
The idea is that I want my web server will be a very simple and light and will only serve static files (html/css/js) - no database on production, no php engine will be installed on server. All the Drupal engine will be on another server, export will be done each time adding/editing/changing a node or view, and a new set of html files will be created in a directory structure.
These files will later on be copied to the production site that will serve always and only static files, no .htaccess that will check requests if file exist etc.

Is there a module for that, or a workaround that this can be achieved with Drupal?

Thanks


texts: Different image width on a node and on block

texts:
I noticed that there are differences in the way inline images are displayed when added to 'Body' of the 'Basic Page' and 'Body' of a 'Basic block'. In the first case the image is internally scaled down to match the width of the container (added attribute 'width=909' [screenshot 1]) whilst in the second case the image spills out over the element [screenshot 2]

I looked at image styles and field display options but couldn't figure out what is causing this behaviour. I'd like to preserve the scaling of the 'Basic Page' for the blocks. Has anyone else come across this issue? I'm running Drupal 8.1.9.

EDIT 1:
 @Smalution I checked the region width, too. Both 'region-content' and my custom region are 940px wide (descendants of 'col-sm-12')


texts: Drupal views grids alternate number of columns per row template preprocessor

texts:
im using views with the grid display option, but my interface requirement needs to alternate between 3 columns then 2 columns.

can anyone recommend and template hooks for the preprocessor to achieve this


texts: Problem with Three hierarchical dropdown for country, state city

texts:
I am new in drupal and I am working on one form where I need to create Country, State and city interdependent,hierarchical ajax dropdowns. So far I could achieve country and state dropdown but while making city dynamic on change of state is not working. It calls same callback and wrapper which I used for country even if I kept them separate. Please check below code

$form['account']['country_id'] = array(
    "#type" => "select",
    "#title" => t("Select your country."),
    "#options" => $countryArray,
    '#ajax' => array(
        'event'=>'change',
        'callback' =>'my_module_ajax_dropdown_state',
        'wrapper' => 'state-wrapper',
    ),
    '#id' => 'country',
    '#required' => true
);

 if (isset($form_state['values']['state_id'])) {
    // Pre-populate options for city dropdown list if province id is set
    $cityOptions = _load_city($form_state['values']['state_id']);
 }

// Options for city dropdown list
$stateOptions = array('- Select state -');
if (isset($form_state['values']['country_id'])) {
    // Pre-populate options for city dropdown list if province id is set
    $stateOptions = _load_state($form_state['values']['country_id']);
}

$form['account']['state_id'] = array(
    "#type" => "select",
    "#title" => t("Select your county/State."),
    '#prefix' => '
',
    '#suffix' => '
',
    "#options" => $stateOptions,
    "#ajax" => array(
        'event'=>'change',
        'callback' =>'my_module_ajax_dropdown_city',
        'wrapper' => 'city-wrapper',
    ),
    '#default_value' => '--Select State--',
    '#id' => 'state',
    '#required' => true
);

$form['account']['city'] = array(
    "#type" => "textfield",
    "#title" => t("Enter your city."),
    '#id' => 'city',
    '#prefix' => '
',
    '#suffix' => '
',
    '#required' => true,
    '#default_value' => $account->city
);

These are my callback functions which are returning form element

function my_module_ajax_dropdown_state($form, $form_state){
  return $form['account']['state_id'];
}

function my_module_ajax_dropdown_city($form, $form_state){
 return $form['account']['city_id'];
}

I am trying to figure it out but no success yet. Please help me.

Thanks


texts: Programatically load title of a views page by its machine name

texts:
I would like to use the current title of a very specific views page in another template. Instead of just manually copying it and in order to stay flexible and always up to date, I would like to programatically load and insert it.

If my views page has machine name views_page, how do I programatically load its current title into a string?


texts: Make one reference and load the other automatically (Entity Reference)

texts:
I have a content type "songs", lets say a node has a reference to 4 or 5 other nodes.
What I want is when I create a new node, I just need to make a reference to one node and the other 4 nodes will be loaded automatically.

Is that possible?


texts:
My site has an administrator role (editor), and I want to allow the anonymous users to submit articles in my site; the node they create must be approved by editor users, before to be published.
I have been told to use the Workflow module; I installed the module, and set it, but I didn't obtain what I wanted.

These are the steps I followed:

I created a workflow which is named "teststory",  and added the "approve" state, which is applied only to the "story" content type.
I edited the workflow, which is then shown as

   from/to     approve
   (creation)  checked the author and authenticated user
   approve     nothing

Under the "access control" approve part, I allowed the authenticated user to view, edit, and delete the posts that are in this state.


texts: Way to display View block only when a specific option is selected in Facet

texts:
I have a view block which I want to display on page only when a specific item in facet is selected (eg Year) .
I am struggling to get this done , I tried with contextual filter but it seems it doesnt work with Solr index .
Any pointer on how can i control the behavior of display of my view block on facet combo.

Thanks!
Carol


texts:
I am building a multilingual site using Drupal 7. I have used Views to generate a page, and in that page I have added a link in the view footer. The custom code that I use in my views footer is as below.

<?php To blog archive

My problem is that I am using i18n module to translate the contents. In the translate interface I get the full above code, and as a result I lose my footer in views. Is there any way by which I can translate the "To blog archive" instead of the full code?


texts: Dropdown menu with descriptions only in sub-menu elements in Drupal 7?

texts:
I'm trying to implement a dropdown menu in my custom theme. At the moment, this means I have a region for the primary and another region for the secondary menu.

According to the design I would like implement, the description of a menu element should be visible - but only for sub-menu elements, like in this menu:

My problem is the following:

I can't find a way to handle different levels of menus accordingly, i.e. to add the markup of the descriptions only where necessary and the different classes on ULs.

How should I implement this kind of menu?

[I've installed the Menu Block module for some help with this. It adds several new hooks that might be useful, but we will see...]

Thanks for checking out this question!


texts: Twig/Drupal 8 custom cache context not working in node preprocess?

texts:
I have a twig template that must be rendered differently on smaller displays (mobile devices) or a larger displays. For example, my breakcrumb is moved to the footer for mobile devices.

In order to check the device type, i use Mobile Detect module and i have created a new cache_context named "mobile_detect". I want to use this cache_context in my "node--page.html.twig".

Currently the cache context seems to work only when i'm logged in as "super user" but when i'm not logged in, the node is cached once and the cache context is not used.

Do you have any ideas why this doesn't work ?

Thanks a lot and Sorry for my bad English :(

My preprocess :

function theme_preprocess_node(&$variables)
{
    //mobile detect variable
    $mobileDetector = \Drupal::service('krs.mobile_detect');
    $variables['isMobile'] = $mobileDetector->isMobile();

    //cache context
    $variables['#cache']['contexts'][] = 'mobile_detect';

}

My twig :

{% if isMobile %}
  {# content for mobile device #}
{% endif %}

My cache_context service :

file located in my module modules/custom/customCacheContext/src/Cache

<?php

namespace Drupal\customCacheContext\Cache;

use Drupal\Core\Cache\Context;
use Drupal\Core\Cache\Context\CacheContextInterface;
use Drupal\Core\Cache\CacheableMetadata;

/**
 * Defines the MobiledetectCacheContext service, for mobile or desktop caching.
 *
 * Cache context ID: 'mobile_detect'.
 */
class MobiledetectCacheContext implements CacheContextInterface  {

    /**
     * Constructor
     */
    public function __construct(MobileDetect $mobileDetector)
    {
        $this->mobileDetector = $mobileDetector;
    }

    /**
     * {@inheritdoc}
     */
    public static function getLabel() {
        return t('Mobile Detect');
    }

    /**
     * {@inheritdoc}
     */
    public function getContext($parameters = NULL) {

        if($this->mobileDetector->isMobile()) {
            return 'mobile';
        }

        return 'desktop';

    }

    /**
     * {@inheritdoc}
     */
    public function getCacheableMetadata($parameters = NULL) {

        return new CacheableMetadata();

    }

}

My cache_context service.yml:

services:
  cache_context.mobile_detect:
    class: Drupal\customCacheContext\Cache\MobiledetectCacheContext
    arguments: ['@krs.mobile_detect']
    tags:
      - { name: cache.context }


texts: How do you output a $row->field_data in a custom views PHP field?

texts:
I have the following Custom PHP Views field: http://prntscr.com/1dd8m0

I did a print_r($row), but I keep getting output that doesnt match what I have in those fields: http://prntscr.com/1dd9ls

Does anyone know why?

My end result is to be able to do a preg_replace() on the fields loaded before it. End result would be:

  print preg_replace('foo','bar', $row->path);


texts: Programatically get a list of node ids of a content type for a specified language

texts:
From the following code I get all the node ids of content type 'blog'

    $query = \Drupal::entityQuery('node');
    $query->condition('status', 1);
    $query->condition('type', 'blog');
    $query->sort('created', 'ASC');
    $entity_ids = $query->execute();

I want to retrieve all the node ids of specific language.
Eg. Node ids of content type 'blog' for 'French' language.


texts: jQuery Draggable plugin integration with Views 3

texts:
I want draggable and sortable contents by admin. So, installed jQuery UI and put this code in my main.js:

$(function() {
    $( ".panels-flexible-region" ).sortable({
      revert: true
    });
    $( "#makyaj .views-row" ).draggable({
      connectToSortable: ".panels-flexible-region",
      helper: "clone",
      revert: "invalid"
    });
    $( "ul, li" ).disableSelection();
  });

Yes, it works. But i want use this option only admin user. Whether View Sort Type: Jquery Draggable and qhat sets the admin users so they can see it.

Is it possible? Can i integration Views and jQuery UI Draggable?


texts: Where can I find an exhaustive reference of the Views module

texts: I am new to the views module and am trying to get my head around how it works and what the possibilities are with it. Is there a resource, book, video tutorial, or site somewhere that does a good job of explaining the whole module from beginning to end?


texts:
Does anyone know how to add the Panels > Settings > General > 'Make all views available as panes' checkbox to a feature?

I guessed the Strongarm box but I don't see the setting.


texts: How to show conditional tab in webform 7.x-3.x

texts:
I created an enquiry form using the webform 7.x-3.x module and I want to create condition on field, but not showing conditionals tab.

I also use webform_conditional 7.x-1.0-beta2 but conditional tab not  showing.

But,
I create again enquiry form from webform 7.x-4.x Module. In webform i show conditionals tabs.

My question is how to show conditions tabs in webform 7.x-3.x. I not want to upgrade module webform 3.x to 4.x.

Have any configuration or module to show conditional tab.


texts: How to reverse a drupal patch on netbeans

texts:
Is there a way to reverse a patch on Netbeans?

Does simply copying the target file and repasting it will work?

Or can the patch affect mutliple modules and code?


texts:
I have a Drupal Commerce site and I'd like to apply a discount to the price where it is calculated. I have a table in the profile user with SKU | discount pairs and I'd like some way (maybe Rules?) to search the product on the table and apply the discount to the price.

Is there any way to do this in Drupal Commerce?


texts:
I created a module to generate and display demo content; I would like to know if I can use Twig inside my pricing-table.html file and use a function to convert all data to HTML to use for #markup.

How does Drupal 8 convert Twig in HTML?

  public function princingTablesPage() {
    return array(
      '#title' => 'Pricing Tables',
      '#markup' => file_get_contents(__DIR__."/../../demo_pages/pricing-table.html")
    );
  }


texts: How to prevent a node from being saved/updated by using the Rules module?

texts:
I've created a content type 'H'. The following rule (using the Rules module) has been built to prevent the node from being saved/updated if the field 'a' is larger than 5.

Event: Before saving content of type 'H'.

Condition: Data Comparison - Node field 'a' is larger than 5.

Action: Show a message on the site - Message type: Error.

Action: Go back to the front page.

It will show the error message if the condition is TRUE. However, the node is still being saved/updated.

Is it possible to control this without programming?


texts: How to implement moderation of data entered through user profile pages?

texts:
I am in need of a means of moderating data entered through a user's profile page, or at least for certain specified fields, both upon initial submission and after any revision. These are fields that have been added to the basic user profile (example.com/user/#), editable through the "my account" link -- fields that can be added through Home » Administration » Configuration » People » Account settings.

The most important fields to moderate involve text entry fields and selected taxonomy terms. By moderation, I mean administrative approval of the changes before they go live on the site. My preference would be for the old data to remain visible pending approval of the new data.

I hired a web development company to create a site that includes a directory, with the explicit instruction that moderation of directory data was necessary. They nonetheless set the site up such that the information is provided through fields on users' profile pages and did not incorporate any means of moderation.

I have seen a potential work-around that involves the installation of the Profile2 and Profile2 Moderation modules, but simply implementing those modules does not fix the problem and creating new profile pages would unfortunately risk breaking the site.

If you have any ideas, I would be very grateful to hear them.


texts:
I'm getting the error Notice: Undefined index: #value in element_validate_integer_positive() (line 4190 of includes\form.inc) after clicking the Upload or Remove of a managed_file even though the file is actually being stored in the correct directory.

Here's the relevant snippet:

$form['some_image'] = array(
    '#title' => t('Image'),
    '#type' => 'managed_file',
    '#description' => t('The uploaded image will be displayed on this page using the image style choosen below.'),
    '#default_value' => variable_get('some_image', ''),
    '#upload_location' => 'public://some_images/',
  );

I'm running the instance on XAMPP with PHP 5.3.6. Downgrading to PHP 5.2.9 didn't fix the problem as indicated in the other forums.

When I use Chrome to checkout the ajax request URL, I see the message that is also seen from looking at file/ajax/image/file/form-wRaEJ-JRPqC7q6BSbp6Ccxi_9X1cpiaBzhwlIs9NFd0 that I found from /admin/reports/dblog

  Error message An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (512 MB) that this server supports.

Note that I'm only uploading a 100kb file.

Line 4190 of includes/form.inc is as follows:

function element_validate_integer_positive($element, &$form_state) {
  $value = $element['#value'];
  if ($value !== '' && (!is_numeric($value) || intval($value) != $value || $value <= 0)) {
    form_error($element, t('%name must be a positive integer.', array('%name' => $element['#title'])));
  }
}

Update: It turns out the problem is not just for the managed_file, but also for the form itself. Clicking the submit button shows the very same error.

Currently, my hook_form_validate is as follows:

function mymodule_form_validate($form, &$form_state) {
}

Removing it gives me a Drupal error that says it should be there. I think I'm missing an implementation some other hook, but I have no idea which.

What am I missing here?


texts: How to create a redirect for specific domain?

texts:
I'm using Domain Access and Redirect modules. Both work well.

But Redirect module only allows me to create redirects from relative path which affects as follows all my domains.

So how to create domain-specific redirect?


texts: Form in controller does not render as usual

texts:
In Drupal 8.4.3, I tried to render a form inside a controller's method, but it does not render as usual.

The value of #default_value is not taken into account
Fields have no name attribute (which causes them not to be sent)

This is the smallest code I've been able to write to reproduce the issue.

public function list()
{
  $render = array(
    '#type' => 'form',
    'search' => array(
      '#type' => 'textfield',
      '#title' => 'Search',
      '#default_value' => 'Lorem ipsum'
    ),
    'actions' => array(
      '#type' => 'actions',
      'submit' => array(
        '#type' => 'submit',
        '#value' => 'Apply'
      )
    )
  );

  return $render;
}

The rendered markup is the following.

<form method="post" accept-charset="UTF-8">

    Search

    <input type="text" size="60" maxlength="128" class="form-text">

  <input type="submit" name="op" value="Apply" class="button js-form-submit form-submit">
</form>

The sent data is the following. Obviously, the search field is not sent as it does not have a name.

op=Apply

I can overcome the missing name attribute with a #name key, but I cannot understand why it is needed here, but no where else.

This is the most basic route/controller pattern.

What could interfere in my context?


texts: A different template based on a taxonomy term in views

texts:
I'm using drupal 8.

I use the view provided by default: "taxonomy term".

I would like to make a presentation of the page (and not only of the node) different according to the term of taxonomy.

I tried with this code (in .theme) and template suggestion :

use Drupal\taxonomy\Entity\Term;

function THEME_NAME_theme_suggestions_page_alter(&$suggestions, &$vars) {
  if (\Drupal::routeMatch()->getRouteName() == 'entity.taxonomy_term.canonical' && $tid = \Drupal::routeMatch()->getRawParameter('taxonomy_term')) {
    $term = Term::load($tid);
    $suggestions[] = 'page__taxonomy__' . $term->getVocabularyId();
  }
}

But it does not work because (i think) it is a view.

I tried with the views template suggestion but it works only for the whole page and not for each taxonomy term.

Does anyone have the solution ?


texts: Detaching Drupal Behaviors of another module

texts:
I'm using this module External Link module which adds "ext" as a class to any anchor tag matching the regex defined via the admin UI provided by the module. I then bind a click event to trigger colorbox for anchor tags with the "ext" tag. Now my issue is, any anchor tags added to the colorbox container are also being added a class "ext".

I understand that this has to do with Drupal.behaviors attach method implemented in the contrib module, but how do I "detach" this behaviors from my custom js file? Specifically for the links within the modal container.


texts: Custom content types and fields: how do I set it up properly?

texts:
I'm looking for a check-list style explanation of how I create this custom content type if possible.

I'm scraping data from an external website (it works flawlessly), I store it in my own database table (hook_schema(), etc.), and I display it in my config page as a table. The data gets re-scraped on cron using the queue API built into Drupal.

All this works fine. Now, my next step is to have this data turned into nodes as a custom content type. I will never need to create nodes of this content type by hand through the 'Add Content' menu because all the nodes should be generated by my module's scraping/parsing function, but the content should be searchable with Drupal's built in search. This is a bit more of a challenge. I have multiple fields (10-ish) I want to sort my data into, all different sections of the pages I'm scraping and I want to keep them separated properly so I can theme the content with a tpl file. The fields are all text, mostly HTML, some are titles/subtitles with no HTML, and a few Unix timestamps.

This has to all be done programmatically because this module might be deployed to other websites in the future, and this should not require configuring to work.


texts: How to enable modules through configuration?

texts: I am trying to enable modules by adding them to core.extension.yml file without getting involved with Features, Configuration Installer or similar modules or profiles. The modules are enabled but their default configuration under module_folder/config/install or module_folder/config/optional are not imported. Is there a way to do this?


texts: display the multiple value in single field in drupal 7 view

texts:
display the related multiple value in single field to avoid duplication in drupal 7 view

Guys help me to solve this issue.

Now it's like this.

Name -----------------------------Organization

sam --------------------------------Ministry of public Health

sam ---------------------------------It solution company

I want to display like below

Name------------------------------Organization

sam----------------------------------Ministry of public Health, It solution company


texts:
I am building a module that will create webforms for use with the Commerce Webform Order module. These must be somewhat constrained in their structure, so I have developed a form (using FAPI) to configure them.

Well, the form has become rather complex, with several "add another" fields and the like.  The Webform module handles these rather elegantly, and I'd love to use its capabilities for my module's config page, but feel that a traditional webform would be subject to error and fiddling.

The config page must look at a given webform (if specified) and use its content to pre-load values, or create fields, to allow for further settings adjustment (e.g. prices of items, additional fields, etc)

So, is it feasible to somehow invoke the webform module to create something that works like a webform but is under the control of my module?

Thanks in advance.


texts: Saving the value for a taxonomy term field

texts: I'm trying to save a field value for a taxonomy term, my value appears in the term array, but the "fields" array is empty. I'm not sure if it's right what I am going to do. You can see everything about my case in the attached screenshot.


texts: How do we use drupal_add_library(), drupal_add_css() and drupal_add_js()?

texts:
How do I use drupal_add_library(), drupal_add_css() and drupal_add_js() in Drupal 8?

I am porting a module that uses those functions. I am following what reported in this post, which says these functions have been removed in favor of #attached, but I am not able to attach these files to my configuration page.

The error I am getting is the following:

  Uncaught PHP Exception LogicException: "You are not allowed to use js in #attached"

How do I attach CSS and JavaScript to a page?


texts: Do I need BOTH jQuery wrappers or just one?

texts:
[Drupal 7.43]
[Production Linux Environment]
[Omega4 Sub-Theme]
[jQuery-Update-Module-7.x-3.0-alpha3]

(Some Questions) I am using jQuery on my website to accomplish several fixes:

Make iPhones respond to Hover Events.
Add a Div-wrapper to enclose a group of Navigation-Links.
Create an Accordion Navigation Drop-Down.
Stop Google-Maps-Windows from scrolling in Mobile environments, eclipsing the regular page scroll.

I have integrated jQuery using the MyTheme-Info strategy.  That is, that I have added the script-tag of the fixes individually to the MyTheme.info file.  Then I have uploaded the corresponding Fix-01.js files to the server.  Basically, this seems to be working, but I have some questions and these concern the BONUS weirdness that Drupal adds to the already amply weird jQuery itself.

I know that I have to wrap the "Fix-0x.js" files in the code:

Code Wrapper #1

(function ($) {
   //Some amazing code here
}(jQuery));

As I understand it, this allows jQuery to use the '$' symbol without clashing with other libraries that also use this same symbol.

I know that jQuery also MUST wait for the DOM to load before the script can have any access to the elements of the DOM.  Often this is done with the  code:

Code Wrapper #2

$(document).ready(function() {
    //Some amazing code here
});

Or sometimes it is written:

Code Wrapper #3

$(function() {
    //Some amazing code here
});

The question is, does the first jQuery wrapper (Code-Wrapper #1) include the Document-Ready function or not (Code-Wrapper #2).  Do I have to wrap the jQuery in BOTH wrappers?  I know that Code-Wrapper #2 and Code-Wrapper #3 are equivalent.


texts: How can I format the content in horizontal tabular form?

texts:
I'm using Drupal 7 and below you can see an example of what I want to achieve. Basically I have a specific content type that I want to display as seen in the image.

On the left I want to list some fields of my content type and on the right some content
elements. Basically it's a horizontal table. Also I would like to be able to format each row individually.

I already know that I could do it with the Panels module by creating a variant in the Node Page with a selection rule for my content type and by then adding the nodes manually to a Panel Page.

But that doesn't feel like the most elegant solution. Isn't there a possibility to arrange the content in a view as I want to do it? What approaches would you suggest me?


texts:
I'm using Membership entity commerce (7.x-1.0-alpha2) for my website.
On the join page, I'd like to reorder the membership types : I got "one month", "three months" and "one year", but they don't show up in the desired order... Plus I would like to customize this form (hide description and term length). I've been trying to change different things in the module's code with no luck.
Any ideas ?


texts: How to set programmatically Line Item Price?

texts:
I just managed to add programmatically a line item (type: product) to my order.

I struggle to set the price for this item now.
How can I set the price at the same time when adding such an item (and having the total calculated accordingly)?

This is how I can successfully add a product:

 $product_id = XXX;

// Load whatever product represents the item the customer will be
// paying for and create a line item for it.
$product = commerce_product_load($product_id);
commerce_product_save( $product );

$line_item = commerce_product_line_item_new($product, 1, $order->order_id);

// Save the line item to get its ID.
commerce_line_item_save($line_item);

// Add the line item to the order
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_wrapper->commerce_line_items[] = $line_item;

// Save the order again to update its line item reference field.
commerce_order_save($order);


texts:
In my project, I am using "Printer-friendly pages" module in order to add print button to my project.

for example when a user is in "checkout/5/review" page, print module create a page with "print/checkout/5/review" address.

this process works fine but I want to alter the created page for printing "print/checkout/5/review"

I tested hook_page_alter but it doesn't work.


texts: How to show all template suggestions for a page without using Devel Themer?

texts:
For some reason the Theme developer module doesn't work on my site (whenever i activate it and navigate on my site it just shows a white page with written "Jump to main content"), but all I want to know is which TPL files are being used to render my current page.

I know that if i put print_r($variables["theme_hook_suggestions"]); in preprocess_html or preprocess_page functions (or any other preprocess function for what it matters) I'll be able to see the suggestions for the html.tpl.php and page.tpl.php files respectively, but i actually need to go deeper and see all the template suggestions that are being checked to render the current page.

Is there any way to do this without using the Theme developer module?


texts: Access denied for user anonymous while accessing custom table data

texts:
I am trying to fetch custom table result anonymously with services but I am getting

<?xml version="1.0" encoding="utf-8"?>

Access denied for user anonymous

My Code are as follow :

    function custom_data_services_resources() {
  return array(
    'getdata' => array(
      'retrieve' => array(
        'help' => 'Retrieves a data',
        'file' => array('file' => 'inc', 'module' => 'custom_data'),
        'callback' => '_get_data',
        'access callback' => TRUE,
        'args' => array(
          array(
            'name' => 'id',
            'type' => 'int',
            'description' => 'The id of the note to get',
            'source' => array('path' => '0'),
            'optional' => FALSE,
          ),
        ),
      ),
      'index' => array(
        'help' => 'Retrieves a listing of notes',
        'file' => array('file' => 'inc', 'module' => 'custom_data'),
        'callback' => '_get_data',
        'access callback' => TRUE,
        'args' => array(
          array(
            'name' => 'page',
            'type' => 'int',
            'description' => '',
            'source' => array(
              'param' => 'page',
            ),
            'optional' => TRUE,
            'default value' => 0,
          ),
          array(
            'name' => 'parameters',
            'type' => 'array',
            'description' => '',
            'source' => 'param',
            'optional' => TRUE,
            'default value' => array(),
          ),
        ),
      ),
    ),
  );
}

I tried with "X-CSRF-Token" also But no luck :(

Any help appreciated


texts: How to desactivate jquery_update logic for the homepage

texts:
The objective of this is to remove all legacy javascript files from the homepage except for the new javascript files I specifically want to load.

Here is how I remove all the Javascript files I don't need:

function phptemplate_preprocess_page(&$vars) {
    $template_files = $vars['template_files'];
    $scripts = drupal_add_js();

    if (in_array('page-front', $template_files === true) {
        // Here I unset all the javascripts that I don't want to be loaded in the homepage
        unset($scripts['theme']['themes/"theme_name"/js/jquery.jcarousel.min.js']);
        ...
        // Once cleaned up all unncessary javascripts, I load them into $var['scripts']
        $var['scripts'] = drupal_get_js('header', $scripts);
    }
}

This works fine, however it only works when the jQuery Update module is desactivated. If the jQuery Update module is active, somehow it overseeds this logic and all the javascript files are loaded anyways.

I don't want to use the jQuery Update logic in the homepage, but I'm affraid that if I disable this module, I can provoke negative side effects in the other pages of the website.

Conclusion: I want to desactivate jQuery Update logic for handling javascript files but only for the homepage.

Any other alternative solution / conclusion to this problem is also welcome.


texts: Restrict admin/content view by organic group membership

texts:
I'm using D7 with organic groups. Have 7 groups each with their own content.  Anonymous users can view all content from any group.  Group admins can only edit the content from their own group.

When a group admin goes to admin/content they see all content items, though they can only edit their own.  Is there a way to restrict the output on admin/content so the group admin can only see their content on this page?  This would make it easier for them to review and manage their content as they would not need to page through all of the site content.

Thank you


texts: why can I not extract the line item from the token

texts:
I have an online store and would like to extract the purchased line item at check out for further processing in php. Now, I have enabeled  tokens in my PGP Code text format and have moved processing of the tokens before the PHP evaluator.  i have run a test with the order number in my checkout message and it works fine with it but for some reason, it does not let me interpret, print or process the line item token:

<?php
echo "Hello World!
";
echo "[commerce-order:commerce_line_items]";
echo "Order number: [commerce-order:order-number]
---------------
";
?>

Doesn't print anything on checkout, however

<?php
echo "Hello World!
";
echo "Order number: [commerce-order:order-number]
---------------
";
?>

prints the order number as expected and moving the [commerce-order:commerce_line_items] outside the <?php brackets works as expected too. I'm perplexed, what am I possibly missing?

Thanks for any support with this!


texts:
Is it possible to have client specifik prices for products in Commerce?
This should be an option with specific clients that has an agreement with the company. Everyone else will pay the ordinary prices.


texts: Top 10 priorities in performance optimization of a complex Drupal site

texts:
I read a lot about many ways to improve drupal site performance optimization, but I did not find a clear indication of the top 10 most relevant modifiations for optimizing the performance of a complex site.

I currently am working to optimize a very complex site that has completely grown out of hand and needs serious modification because current page load speed is about 4 to 6 seconds for authenticated users.
The website is mostly being used by authenticated users. The only access restriction is present through the Organic Groups module.

Current state:

90 node types
140 select boxes checked on the admin/modules page
63 Vocabularies
240 views (excluding the additional views displays)
30 rules,
50 rules components
130 node panel variants
10,000 lines of css (excluding the omega base theme and modules style
sheets)

What is the most important to start with, in general?


texts:
I am using the formapi to create a form. On one of my fields I have an #ajax call. When the field is changed I call the function. I recreate the form and then replace the whole form on the page. This works fine.

When creating the form I have some logic that sets the form state to see if a field has a value. If it has a value then I show some more fields. If the value is not set then I don't show the fields. I am showing the fields by setting the #access on the field.

I need to add some validation on the form when the ajax call is triggered. I have tried adding the validation using form_set_error() in the function that creates the form and in the ajax callback but the error is not displayed on the screen.

Am I going about this the wrong way completely? How can I get the form error to display?


texts: How do I block individual content items from search engines?

texts:
I need to create multiple landing pages for my food business running a Drupal 7 site, same page, different prices, offers, coupons, different OGP tags for Facebook posts etc.

So I will have dozens of multiple identical content pages, and I don't want to be penalized by Google. I could do this via Robots.txt or .htaccess, but is there a way to do this at the content page item level?


texts:
I'm attempting to understand the concept of entity storage. For example in this tutorial

https://www.sitepoint.com/drupal-8-version-entityfieldquery/

it's using code to load the nodes from nids in a similar way to this

$ids = \Drupal::entityQuery('node')
    ->condition('status', 1)
    ->execute();

$node_storage = \Drupal::entityManager()->getStorage('node');

// Load multiple nodes
$node_storage->loadMultiple($ids);

But I'm not sure exactly what this is doing

$node_storage = \Drupal::entityManager()->getStorage('node');

My best guess is that it's loading the format of how the node is stored in the database so it knows how to load everything based on that format, but that's just a guess.

Also side note: the path I normally take is doing a foreach loop on the query results and loading the node based on the nid inside that. Like so. But I'm not sure what's best practice.

        foreach ($ids as $nid) {
            $node  = Node::load($nid);
        }

What exactly is entityStorage, and what function is it providing?


texts:
How can i add a new tab in node tabs ( with edit, view tabs ) and show a page on this new tab ?
i am working on a shopping cart where i need to add a new configuration tabs with nodes and ubercart products.


texts: How to implement a Drupal Commerce multi-select membership donation form?

texts:
Something like this using Drupal Commerce? You select from a select list multiple options of which everyone has a price right? And so it adds it as a total below in a field like a cart, but in a same page and then below you fill your details and continue?

Or not a chance with Commerce and have to go with some other alternatives? Note I'm looking for Drupal friendly solution, not a PHP programmer here.

Cheers everyone for help!


texts:
I am using Drupal-7. I am trying to build a Fly out menu that have images, content blocks.

I am using the MuchoMenu to create top menu into my site.

I wanted to create Flyout menu same like displayed in Mucho Menu with image block.

I have created Main MuchoMenu, Mini Panels, Content Types to display images and content blocks.

But, my Menu Items are not displaying into my website. Do I have to add anything into my page.tpl.php or page--front.tpl.php pages? I have added Main MuchoMenu block into "Main Menu" Region.

In both page.tpl.php and page--front.tpl.php files, I have added this into menu section:

        <?php if ($main_menu): ?>

            <?php print theme('links__system_main_menu', array(
              'links' => $main_menu,
              'attributes' => array(
                'id' => 'main-menu-links',
                'class' => array('links', 'clearfix'),
              ),
              'heading' => array(
                'text' => t(''),
                'level' => 'h2',
                'class' => array('element-invisible'),
              ),
            )); ?>

        <?php endif; ?>

    <?php if ($secondary_menu): ?>

        <?php print theme('links__system_secondary_menu', array(
          'links' => $secondary_menu,
          'attributes' => array(
            'id' => 'secondary-menu-links',
            'class' => array('links', 'inline', 'clearfix'),
          ),
          'heading' => array(
            'text' => t(''),
            'level' => 'h2',
            'class' => array('element-invisible'),
          ),
        )); ?>

    <?php endif; ?>

Please let me know as I am new to Drupal.

Thanks!


texts: Removing potentially malicious code from template

texts:
Our drupal site was hacked at some point recently, and I've been tasked to clean it up because nobody knows much about drupal here. I think I've taken care of most of the glaring security holes, and updated all the modules I could, but I've discovered there's still some gibberish/potentially malicious code on the site that I can't seem to track down.

At the top of every page drupal includes the site's CSS files, and then there's the three IE conditional blocks that are included in the seven_preprocess_html() function in themes/templates/seven/template.php. Immediately below those conditionals is the following block (I can't actually include the code because SE won't allow the characters in the textbox):

Then there are a series of legitimate .js script tags immediately below. The code in that block is throwing illegal token errors, and appears to be breaking other things in the page. I don't know if it's actually malicious or a corrupted file/db, but I obviously want it gone. Unfortunately I can't find it anywhere in any of the template files and I'm running out of places to look.

Anybody have any ideas on where this block might exist or how I can remove it?


texts: Theming a custom data table from php code text format with Drupal 7

texts:
I have a working block of php code that runs inside a Drupal 7 Page:

<?php
$my_database= array(
  'database' => 'mydb',
  'username' => 'xxxxxx', // assuming this is necessary
  'password' => 'xxxxxx', // assuming this is necessary
  'host' => 'localhost', // assumes localhost
  'driver' => 'mysql', // replace with your database driver
);
Database::addConnectionInfo('database_db', 'default', $my_database);
db_set_active('database_db');
$sql = "SELECT tcol1, tcol2 FROM mytable LIMIT 10";

$result = db_query($sql);
$header = array('Col1', 'Col2');
$rows = array();
if ($result) {
  while ($row = $result->fetchAssoc()) {
    $row= array($row['tcol1'],$row['tcol2']);
  $rows[] = $row;
  }
}
db_set_active();
print_r($rows);
$output= theme('table', $header, $rows);
?>

This piece of code works fine and print_r() prints all the data I asked for.
The odd thing is that the theming fails totally, showing nothing. I have done some experimentation:

    $output= theme('table', $header, $rows);
    echo theme('table', $header, $rows);
    print theme('table', $header, $rows);

but all of them fail, showing nothing or disrupting drupal globally.
How can I show my data in a nice table? I want to avoid writing html code and instead rely on Drupal theming.


texts: How do I add custom meta tags to a view page?

texts: There doesn't seem to be an answer for Drupal 8 yet. I have the metatag module installed, it's a great module, but doesn't seem to address views at all. This post for Drupal 7 says that it comes with a 'metatag views' module, but, this doesn't seem to be true for Drupal 8. I've also tried to install metatag quick, but, that fails to do anything at all. So I'm stuck. Is there a way to do this programmatically in D8? How can I get this done?


texts: How to print a string for flagged nodes?

texts:
I have a flag called "Mark as SOLD" which can be flagged only by node author. When he flags it as "Sold", I want the node teaser to print a translatable string t('SOLD'), so that everyone else (even anonymous) can see that this item is now sold.

In my corolla template.php I already have custom function that gives classes to different flags:

    function corolla_preprocess_node(&$variables) {
  $flag = flag_get_flag('sold'); // Machine name of your flag.
  if ($flag && $flag->is_flagged($variables['node']->nid)) {
    $variables['classes_array'][] = 'node-flag-sold';
  }
$flag = flag_get_flag('withdraw'); // Machine name of your flag.
  if ($flag && $flag->is_flagged($variables['node']->nid)) {
    $variables['classes_array'][] = 'node-flag-withdraw';
  }
}

But I know that I need to modify this function and/or node--type.tpl.php to actually print a string t('SOLD').

How can I achieve this?


texts: regex works in PHP fiddle but not in Drupal

texts:
I am having a problem getting some regex to work in Drupal. The below regex works fine:

<?php
 $test = "1111~~test1<>2222~~test2<>3333~~test3<>44444~~test4<>11112~~test5";
 $regex = '/~~(.*?)(<>|$)/';
 $matches = array();
 preg_match_all($regex,$test,$matches);
 $test = implode(', ', $matches[1]);
 print_r($test);
?>

But when I try to use this to parse the contents of $items[0]["#markup"] in my field file it does not work, even though the content of that field are the same (look at it through print_r). This code works inside the tpl file, but as soon as I replace $test with $items[0]["#markup"] it stops working, does anyone know why this could happen?

EDIT: I think part of the issue is that regex in Drupal may not work with <> tags?

Thanks


texts: Stop caching for a specific node (by nid) Drupal 7

texts:
Ideally i want to set custom params for caching in some particular nodes using conditions in my template.php

E.g. algorithm: for node with known nid set custom caching params

But that's enough for my purpose simply exclude from caching particular node.
I fond this solution: Stop caching for a specific node type Drupal 7 this is exacly what im looking for but how i can change condition of checking from node type to nid.

I know about CacheExclude module, but for me unwanted to install module for just exclude one node for caching.

I'll be very grateful for helping me.


texts: Fixing D7 Bug: Block caching within views breaks JS

texts:
I have a number of block on pages throughout my site which use views. Within these blocks I have slideshows(flexslider) or use masonry to produce a dynamic layout. If I enable block caching the JS within these blocks does not function correctly. Disabling caching on these blocks restores the functionality.

I am hoping to fix this problem and have a cached blocked with it's JS functioning normally.

I have found some information on this exact issue for the flexslider module (https://drupal.org/node/1873970) but it is not a complete fix. It states that the issue is within views and points to an issue there: https://drupal.org/node/1460766 . There is also the SE Q&A  at https://stackoverflow.com/questions/9788138/jquery-flexslider-not-loading-verytime which provides some insight to the issue when flexslide is used as stand alone rather than with views.

There are dozens of issue, especially within Views Slideshow (probably because it is one of the most popular Views Plugins) which make reference to this issue all the way back to 2009 but the are no actual fixes.

It is also worth noting that the page can be cached without JS breaking. It is only when the block is cached that things go wrong. In my current implementation cached page but not block adds ~1.5 seconds in load time.

With Views and JS being so widespread and caching being as important as it is I am surprised this issue has not been solved, or maybe I am misunderstanding the issue.

Has anyone encountered this issue and found a fix for it?

I welcome any comments or feedback that would improve this question or help move towards a solution for this widespread issue.


texts: Drupal private messages database table design

texts:
I am trying to get the raw message data from a Drupal instance running the Privatemsg module.

I have tracked the message data down to the pm_message and pm_index tables but I am struggling to understand the database structure / design.

I am trying to get the author and recipient users for a message, however in the majority of cases the pm_message.author and pm_index.recipient are exactly the same user. How do I get the author and recipient of a message from the database?

I think this maybe due to me not understanding threads in database design (can't see how thread_id is created or relevant), sample query I am running to get the data:

SELECT
author, recipient, body, timestamp
FROM pm_message, pm_index
WHERE pm_message.mid = pm_index.mid


texts: scrolling after posting drupal ajax form

texts:
I am working on an existing site which has a Drupal 8 multi-step form which uses Ajax

Upon submitting the form (on the final step) the page scrolls to the top where a thank you message has been inserted.

I want to change this so it scrolls to a fixed number of pixels bellow the top.

The code which applies the ajax behavior appears to be this

$form['actions'][$button->getKey()]['#ajax'] = [
                    'callback' => [$this, 'loadStep'],
                    'wrapper' => 'multistepform-wrapper',
                    'effect' => 'fade',
                ];

(note i have commented out the 'effect' => 'fade' line in the code to see if this alters the behavior and it does not).

The code which handles submitting on the form appears to be this

public function loadStep(array &$form, FormStateInterface $form_state)
{
    $response = new AjaxResponse();

    //@todo: deal with deprecated drupal call.
    $messages = drupal_get_messages();
    if (!empty($messages)) {
        // Form did not validate, get messages and render them.
        $messages = [
            '#theme' => 'status_messages',
            '#message_list' => $messages,
            '#status_headings' => [
                'status' => $this->t('Status message'),
                'error' => $this->t('Error message'),
                'warning' => $this->t('Warning message'),
            ],
        ];
        $response->addCommand(new HtmlCommand('#multistepform-messages-' . $this->uniqueIdSuffix(), $messages));
    } else {
        // Remove messages.
        $response->addCommand(new HtmlCommand('#multistepform-messages-' . $this->uniqueIdSuffix(), ''));
    }

    // Update Form.
    $response->addCommand(new HtmlCommand('#multistepform-wrapper-' . $this->uniqueIdSuffix(), $form['multistepform']));
    $response->addCommand(new InvokeCommand('body', 'trigger', ['pcaAjax']));

    return $response;
}

I have searched the codebase for javascripts with the 'pcaAjax' event and used chrome dev tools  breakpoints to see what javascript runs when the form is submitted and have concluded that the scrolling effect is handled by Drupals own javascript code.

How can i modify this form to give the behavior which i want?


texts: Using Bootstrap with a Zen subtheme in Drupal 7

texts:
I was wondering if anyone could provide me with some advice on implementing bootstrap in D7 with the a Zen subtheme.

I'm really only using it for the responsive div sizing at the moment - I've got a 3 column layout on my homepage that uses col-sm-4 so that it stacks the columns when you're looking at it on a phone-width browser. I've done quite a lot of customization in my Zen subtheme, so I don't really want to install an entirely new theme (the Drupal bootstrap theme, or Zenstrap, for example).

I've tried a couple of approaches to this. First time around, I just copied the bootstrap css file into my theme's css directory, then included it in the normalize.css file, at the top. This worked pretty well, but it occurred to me that if I wanted to use any of the JavaScript features I wouldn't be able to.

Second time around I tried using the Drupal Bootstrap library module. This is also pretty good, and includes the css and js files on all the site pages.

However, I note that it overrides quite a lot of my existing styles. For example, I've got a number of linked headings on the homepage. I don't really want them to use the link style, but whatever I do in the normalize.css stylesheet, I can't stop my homepage picking up the Bootstrap styles. I guess maybe the theme stylesheet loads before the bootstrap stylesheet.

So I'd like some advice, please. Which of the two approaches is the better way to use Bootstrap? Is there another way that is better than either of those approaches? Is using Bootstrap even the best way to make my site responsive?

Thanks very much.


texts: How to show breadcrumbs for taxonomy terms in Drupal 7

texts: I've just now started working on D7 but I can't figure out how to display the terms in the breadcrumbs as we do in D6( I guess using Taxonomy breadcrumb). Taxonomy breadcrumb module for D7 is in dev release.


texts: How to set the path to images in ckeditor?

texts:
I have a recurrent problem I can't solve.

when working in localhost I use ckeditor to upload images to the body field. These images are shown correctly.

Then after, I upload the site to the remote host and all those images links are broken.

The problem is that the drupal installation on my localhost is inside a folder in localhost like: http://localhost/mysite.com/

In the remote host all the images links have the mysite.compart of the url which of course is wrong. This is not solved by clearing caches.

Localhost (works fine)

http://localhost/mysite.com/sites/default/files/resize/icon-questions-180x127.png

Remote (with the wrong "mysite.com")

http://mysite.dde.oneserver.com/mysite.com/sites/default/files/resize/icon-questions-180x127.png

With no luck I tried with several configurations at: admin/config/content/ckeditor/edit/Full

UPDATE (trying with Pathologic module)
I added these lines in "All base paths for this site" in Pathologic setting at admin/config/content/formats/full_html:

http://localhost/mysite.com/ (this one is where the site was developed)
http://mysite.dde.oneserver.com (this one is where the site lives now)

I ALSO tried adding:

http://mysite.dde.oneserver.com/mysite.com

look the capture:


texts: How to programatically access the value of a taxonomy term reference?

texts:
I have a taxonomy term reference field attached to my user account.

I tried getting the value programatically in the same way as I get the value for text fields, but it doesn't work.

use Drupal\Core\Session\AccountProxyInterface;
use Drupal\user\Entity\User;

$account = User::load($account->id());
// Returns the correct value.
$textfield = $account->get('field_textfield')->value;
// Does not return the correct value.
$termreference = $account->get('field_termreference')->value;

How am I supposed to get the value (name) of the referenced term programatically?


texts: How to show message view containing own and following activity?

texts:
I have created a message view using the Message module. I want this view to show the current user activity and activity of the user he is following using the "follow" flag (user). i.e own + following.

The Message module comes with a "message subscribe" flag, but I do not want to use that. What should be the setting of my view particularly the relationship and contextual filters?


texts: How to change conditions of views filters programmatically?

texts: I have a view with a node type filter. I want to change it in some conditions. How do I change this filter in hook_views_query_alter()?


texts:
I've just installed the Views Slideshow Module and gone threw some tutorials to see how it is installed and how it works. Everything works just fine except that Rewrite Result don't work. No Textbox for editing is showing up when I check Rewrite the output of this field. I've tried both in Firefox and Chrome to see if there was some JavaScript thingy but it wasn't. Anyone else is having this very annoying problem?

Checked status report and found no errors. Cleared all cache too.

Also tried with some old Views that I've created and it don't work on those either now. I've tried to disable Views Slideshow but no change. So this might be some other issue that occurred before I installed Views Slideshow.

Using D7, Views 3 and Views Slideshow 3.1

EDIT: It turns out that it's all settings that can be done from checkboxes are disabled somehow. I've even re-installed the Views Module but no luck. Don't know what's causing this behavior.


texts:
I'm a newbie in drupal. So I have this view which Im saving as a block and the way it displays in the preview of the view and on the page is different. Any ideas?

If you have any questions about my configuration just ask I didn't know what to include :)


texts: Prevent indexing the article content after 15 lines.

texts:
I am using search API and Solr .  I need to index only the first 15 lines of each  article .
the remaining lines after 15 lines has content which i don't want to index .
Please suggest if its possible .


texts:
I've created a custom module to add several submission buttons at the bottom of the form. One submit button should redirect users to their Profile2 profile. The other will send them to the user administration section.

The Profile2 page has a submit button to send them to the user account edit page, or to the user administration section. I was able to do this with rules, but the site admin didn't like that there weren't buttons.

So I've created a custom module to handle this, but the problem is that the data is not saved when one of the custom submission handlers is called.

//redirects to account and from profile are working but submissions not saving

function MY_MODULE_redirect_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_profile_form') {
    if (arg(3) == 'coach'){
        $form['actions']['profile'] = array(
        '#type' => 'submit',
        '#submit' => array('MY_MODULE_redirect_account'),
        '#value' => t('Save and go to Account'));
        $form['actions']['submit'] = array(
        '#type' => 'submit',
        '#submit' => array('MY_MODULE_redirect_admin'),
        '#value' => t('Save and go to Administration'));
    }
    else {
    $form['actions']['profile'] = array(
      '#type' => 'submit',
      '#submit' => array('MY_MODULE_redirect_submit'),
      '#value' => t('Save and go to Profile'));
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#submit' => array('MY_MODULE_redirect_admin'),
      '#value' => t('Save and go to Administration'));
    }
  }
}

function MY_MODULE_redirect_submit(&$form, &$form_state) {
    $user = $form_state['user'];
    $form_state['redirect'] = 'user/' . $user->uid . '/edit/coach' ;
    drupal_set_message('The user account has been saved');
}

function MY_MODULE_redirect_admin(&$form, &$form_state) {
    $user = $form_state['user'];
    $form_state['redirect'] = 'admin/MY_MODULE-user';
    drupal_set_message('Your submission is complete');
}

function MY_MODULE_redirect_account(&$form, &$form_state) {
  $user = $form_state['user'];
  $form_state['redirect'] = 'user/' . $user->uid . '/edit';
  drupal_set_message('The coach profile has been saved');
}


texts: Is there a way to switch the Search form (used in the block) to do a Facet Search instead?

texts:
I am using Faceted Navigation for Search and I want to switch the standard Search block to do a faceted search directly rather than the current situation where I have to switch to faceted search after the standard block shows up.

Is there a module for that, or can it be fixed somewhere in the options?


texts: How to update url_alias after SELECT FROM url_alias

texts:
After a rather clumsy migration by a previous developer, my new client's site has a whole bunch of incorrect paths, which I'd like to update in bulk (nearly 7000 nodes, so I'll not be doing this by hand).

In particular, their forum topics are aliased like "/content/12345" rather than "forum/12345" as desired.

I've pretty much figured out how to do this directly in MySQL, but I've hit a snag - MySQL won't allow me to update a table I've done a select from, at least in this nested query.

Here's my query:

UPDATE url_alias SET alias = REPLACE(alias, 'content/', 'forum/') WHERE alias in (SELECT alias FROM url_alias LEFT JOIN node ON CONCAT('node/',node.nid) = url_alias.source WHERE node.type = 'forum');

and MySQL says:

ERROR 1093 (HY000): You can't specify target table 'url_alias' for update in FROM clause

Perhaps I should give up and do this in two stages in PHP...?
Or is there in fact a way to do this directly in MySQL?


texts: Seperate Drupal instance as files server for other Drupal instances

texts:
My task is to create files gallery which is files library for other Drupal instances.

Other instances can upload files to library and browse them.
File metadata are stored in library (A) and client, but physical file is stored only in A.
So instance A acts like some kind of CDN.

Could someone share with me his thoughts about this problem?
Which modules to use? (besides CDN which I am testing now)

I can accept only free solutions.


texts: Google rich snippets, custom content type

texts:
I use Drupal 7.

I have a custom content type which, among other fields, uses Fivestar ratings.

I would like to have my node content enriched with microdata/microformarts/rdf so that it appears in Google Rich Snippets.

I tried RDF module, but it cannot apply detailed formating at the Fivestar module results, because Fivestar produces rating and number of reviews as one field.

I would like to recreate node.tpl.php, by printing field by field and not just $content.
Also I would like to find out how to break down the fivestar two number results down to each compenents, so that I can put the right microdata in the markup.

More information about rich snippets is at http://www.google.com/support/webmasters/bin/answer.py?answer=99170.

How I can find out the variables and arrays that are used to print the content of a node?

How can I print one by one at node.tpl.php, so that I am able to put the right rich snippets markup in between?

edit: ok, till now I have found about devel module and that I must use dpm($content) inside my node--type.tpl.php. I manage to print render($field_names) of various other fields, but I could not yet understand yet about fivestar module values.


texts: Commerce Kickstart: How To Add Sort Fields To Search API?

texts: I've been playing with the Search API and I can add new Facet Displays and filters, but no matter what I try I can't get any fields other than Price, Latest and Title to appear as Sort options. What's the 'trick'?


texts: Content region not visible in blocks setup page in Sky Adaptive Theme

texts:
I checked the 'content' region, being one of the prerequisite regions and it is present and referenced in the sky.info file as well as in the page.tpl.php.

That is:
(in sky.info file)

regions[content] = Main content

(in page.tpl.php file)

<?php print render($page['content']); ?>

However, when I go into the 'block' setup GUI page, from the regions dropdown, I can not see the 'content' region option.

Any idea as to why its not visible would be great. Cheers


texts:
I have a request for a Clinical Rotation Booking Type system.
Schools/Colleges need to be able to book/reserve Floors in Hospitals.  I've researched and 'tried' to use most of the modules mentioned in the Comparison of Booking System modules.

Example:

Each hospital can obviously have a lot of floors:

[Hospital A]

[2W] //2nd floor West
[NICU] //Neo nate Intensive Care Unit
[2E]
[5E]
etc.

[Hospital B]

[2E]
[2W]
[3W]
etc.

[School A]
[School B]

A use case would be:

School A needs to book Hospital A 2E Floor for 1.5 months
School B tried to book Hospital A 2E but it was already taken by School A.
School B books Hospital A 2W instead.

Each School would have it's own login and would select from a list of Hospitals.

A calendar would show for that Hospital with available time slots.

Any guidance or advice is much appreciated.


texts: Is there a list of default fields and default widgets for drupal 7

texts: Where can I a list of available (in the core) fields and widgets and their names so I can reference them when adding fields to my own node-type definitions ?


texts:
I'm building a Drupal 7 module to create a bespoke field type. I've implemented all the required hooks. My hook_field_formatter_view() function looks like this:

function MYMODULE_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();

  switch ($display['type']) {
    case 'default':
      foreach ($items as $delta => $item) {
                $element[$delta] = array(
                  '#theme' => 'test',
                  '#item' => $item,
                );
      }
      break;
  }

  return $element;
}

I've then defined the theme() function below:

function theme_test($variables) {
    return '
Hello World
';
}

But when I view the page nothing is output. If I look at the recent log entries I see this message:

Theme key 'test' not found.

If I change my MYMODULE_field_formatter_view render array '#theme' value to a built in theme function like 'item_list' it works. But for some reason my custom theme function is not being picked up.

I've rebuilt the theme registry hundreds of times as well as cleared the caches.


texts: Drupal 7 View - How to show content based on conditions

texts:
I've a travel portal and I've create a content type Destinations which I use to create content for main Destination page Continent, Countries, states and cities. This content type has uses Location module as a field.

Then I create a page e.g. Thailand which is of type Destinations.

I've create a block view to show the links to cities/countries/continents on country/continent/main destination pages.

So on my main Destination page I want to list all continents and countries, then on countries pages I want to list all states and cities, on state pages I want to show all cities.

Would it be possible to utilize the Location module to achieve this?

I'm using location to identify many type of content, e.g. Hotels, Places, Museums etc.

Or shall I use Taxonomy/Terms.

Or any other alternative ways to achieve this?


texts:
Are there any CSS Mobile-compatible Theme for Drupal?

Example of a CSS mobile-compatible site: http://framelessgrid.com/


texts:
I'm creating a custom file field display formatter module..
https://www.drupal.org/sandbox/vincer/2779871

Right now it's just printing the URI as..

public://my-file.mid

I'm trying to get the default output that I would get by using the File module - a full path as a link, like..

http://my-site/sites/default/files/my-file.mid

The field_formatter_view looks like..

function fieldmidity_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $settings = $display['settings'];
  $element = array();

  if ($display['type'] == 'midi_formatter') {
    foreach ($items as $delta => $item) {
      $element[$delta] = array('#markup' => $item['uri']);
      // Options for $item; filename, uri, description, filesize, timestamp, fid, uid
    }
  }

  return $element;
}

Based on code I see in the File and Field modules, I'm suspecting that the solution might be more complicated than the approach that I'm attempting.

Any thoughts would be appreciated.


texts:
I am hoping that this enquiry will be a easy one for someone to help shed some light on... I know that in order to create a textarea in Drupal 8 the following code can be used (e.g. render array)

$the_textarea=array(
        '#type' => 'textarea',
        '#required' => FALSE,
        '#ajax' => array (
            // Function to call when event on form element triggered.
            'callback' => array($this->componentCallbackObject,$this->componentCallbackFunction),
            'event' => $this->componentEvent,
        ),
    );

In the above code, a callback is defined using ajax ... this has the result of the code requiring the client to communicate with the server, which then sends back instructions to the client side using ajax... Is there away to get a component to execute some javascript (where the javascript would be loaded when the page in question, first loads) and when either the upkey, downkey or onchange event is triggered for the textarea the javascript, which would already be available to the client would be executed.

The main point here is that the client wouldn't need to communicate with the server, just with the javascript which is loaded when the page first loads e.g. without having to callback to the server and then wait for the server to send back the information.


texts:
This question of how to create such a directory http://gospodar.org/ with ready-made solutions, only to drop down the list was to Ajax?
Catalog at the link above is made by custom module and not very comfortable.
Thanks for any help.


texts: Why are overrides not included in download file?

texts:
I have the problem, that some of my features are overridden and will not be updated after recreation.

For example there is one feature that needs a new dependency and the title of one view was changed.
I want to include these changes in my feature and click on recreate.
When i look into the download files, you can see, that the changes (dependency and view titles) are not included.

If i change the files manually, the feature has the status "Standard".

The feature includes content types, panel pages, fields, views, permissions and some strongarm variables.

Does anybody know, why my changes are not included, when recreating my features?

Drupal v. 7.43
Features v. 7.x-2.10

Thanks for your help.


texts:
I'm trying to build a advanced search for a eRecruiting site build with the recruiter distribution. The Recruiter Distribution comes with 3 different search two for applicant that are What ? (Job Search) and Where (Job Location). The another one is to search for applicants. However they are a lot data on the job description and on the applicant that I wanted to used to be more specific .

For instance, the recruiters should be able to search for be able to search for the following items:

Keyword
Location
Specialty
Employment type

Currently, I have some facets that helps me to make my search more friendly. But when it comes to search many items (such as locations nationwide) it becomes to crowded.

I'm aiming for something similar to  Google Advanced Search but a little bit more simpler.

According to a post Building an advanced multicriteria search one the solution to complete this job is the search api solr module. And I have this part working however he did not explain how to do it. There is another post (Create advanced search) that talks very similar of what I'm asking but nobody replay.

I try to use the Search API Combined module but to be honest is lack of documentation. And it does seem to be clear how to used this module.

What is the best approach to created an Advanced Search (multicriteria search) with search api solr ?


texts: Filter "exposed filter" data based on another "exposed filter"

texts:
I have to exposed filters from 2 vocabularies, filtering results for a page. I'm using views module for this
Is there a way to create a bridge between them ? For example when I select something from the first filter the data from the 2'nd filter will change based on what I selected on first filter, and backwards.

If i'm thinking well there is no way to create a direct connection between those 2 filters (vocabularies), we have to use what they have in common, the content. So i'm guessing I need to get vocaluray 1 terms from the content after filter 2 has selected something.

Filter 2 -> generate content -> generate filter 1 data again

Is there a way to do this without "hardcoding" ? Thanks


texts: How to declare field type DATETIME and set the default value

texts:
I have a problem but with the following code. I am creating the following Schema:

  $schema['billfold'] = [
    'description' => 'Stores example person entries for demonstration purposes.',
    'fields' => [
      'pid' => [
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique person ID.',
      ],
      'data' => [
        'type' => 'datetime_default',
        'not null' => TRUE,
        'description' => 'The date when the update has been done.',
      ],
    ]
  ];

How Can I set the type "Datetime" and default value of ON UPDATE (for istance)???


texts:
I'm searching for a image field in Drupal 8 with support to add images using url input. So when users has an image on his disk he can upload it and if the user has a image somewhere online he can link to it.

Does someone know a module that add this functionality to the image field?


texts: How to theme the create content of custom content type?

texts: I have a custom content type property. The registered user can create the property when logged in. I want to theme the "create property page" the same as the site's default theme. Please let me know how we can theme the "create propery page". Is there any module or do we need to do something else?


texts: Multiple instances of same form in views do not work properly

texts:
I have a funny problem with Drupal 7 and Views.

I created programatically a simple form with two submit buttons (yes / no). This form is displayed on a full view of a node and when the 'yes' is pressed, it goes to a 'review' form which autofills the title with the one from the node. It works very well!

function mymodule_form($form, &$form_state,$nodeid) {
  global $user;
  $form['nodeid'] = array(
    '#type' => 'value',
    '#value' => $nodeid,
    '#access' => false,
  );

  $form['yes_button'] = array(
    '#type' => 'submit',
    '#value' => t('Yes'),
    '#submit' => array('yes_button_submit'),
  );

  $form['no_button'] = array(
    '#type' => 'submit',
    '#value' => t('No'),
    '#submit' => array('no_button_submit'),
  );
  return $form;
}

//Submit handlers
function yes_button_submit($form, &$form_state) {
    $nodeid = $form_state['values']['nodeid'];
    drupal_goto('node/add/review', array('query'=>array('id'=>$nodeid)));
}

I decided to add the buttons on the teasers that I display in a Views block. I call the form through a function which is called via a Global Php field. Here is the code inside the Global Php field, having added 'content: nid' as a hidden field in the view:

<?php
  $bling=mymodule_answers($row->nid);
  echo $bling;
?>

With the bit of code from mymodule_answers:

function mymodule_answers($nodeid) {
  $theform3 = drupal_get_form('mymodule_form',$nodeid);
  $output .= '
'.drupal_render($theform3).'
';

  return $output;
}

My problem is that if the view is something like this:

Node 1
Node 2
Node 3
Node 4

If I press 'yes' on any of the node teasers 2 to 4, then the review form is filled with the title of Node 1... meaning, the one at the top of the list!

I have thought about creating uniquely named forms, but I wouldn't know how to automatically generate the differently named submit handlers. Any ideas?


texts: Same as shipping checkbox in admin is not showing

texts:
While creating an order from Drupal admin section, "Same as shipping" checkbox is not showing, but for normal checkout it is showing.

How do I show the checkbox in the administrative page?


texts: Schedule Migrate to import XML data regularly

texts:
Is it possible to schedule Migrate to import/update my XML regularly, say, once an hour? Maybe in Rules?

EDIT: I have a skeleton of a module written for this now, to hook into Rules.

Event: If there are unimported nodes, or if it has been more than 15 minutes since the last import

Condition: Just the machine name of the Migration, and its enddate timestamp

Actions: I want two, one to do an import and rollback, and another to update and import.

I am having trouble trying to find what functions to call to initiate the actions, and which ones to get my arguments. Is there any good documentation on the core Migrate functions (not field handlers or anything) so that I can see which ones I need?

EDIT 2
I ended up with this cron function. Is this how it's written? And I can put it into my module where the rest of my migration is? I also need to specify that it should update any nodes already imported. How do I do that?

    function mymodule_cron() {
            $last_run = variable_get('mymodule_last_cron', 0);
            $interval = variable_get('mymodule_interval', 60);
            if(time() - $last_run > $interval){
                 variable_set('mymodule_last_cron', time());
                 $migration = Migration::getInstance('ImportNodes');
                 $result = $migration->processImport();
            }
     }


texts: Programmatically add a translation with proper content moderation state

texts:
I am trying to add a node translation programmatically when a node is created (using hook_ENTITY_TYPE_insert). My code works fine except that the translation doesn't really have a content moderation state. My code is the following.
function mymodule_add_translation($node) {
  // get the current language, and determine the translation language
  $lang = \Drupal::languageManager()->getCurrentLanguage()->getId();
  $langcode = ($lang == 'en') ? 'fr' : $lang;
  $node->setRevisionTranslationAffected(FALSE);
  $node->addTranslation($langcode, ['title' => $node->getTitle()])->save();
}

This is what the content_moderation_state_field_revision table looks like for two nodes; the first one was manually translated and the second one was translated using the above code.

I am clearly doing something incorrect. Any suggestion would be really appreciated.


texts: Is db_set_active() need to work with a Drupal database or can I use it with a database that doesn't contain any drupal tables ?


texts: Changing node values directly to database exhibits erratic behaviour

texts:
I needed to create a new field for each node in my website that would have as its value a concat of two existing fields.

I firstly inserted the new rows in the newly created field table, and then updated each of the rows with he corresponding information.
But when I check on the browser in the edit page of several nodes some of them have the correct value inside the field while others have that field blank. The strange part is that there is no apparent difference in the database between the nodes with a value in the field and those that have it blank.

After investigating the issue I copied all the table to its correspondent revision table, leaving revision_id as 0. This didn't solve the problem.

I know I'm not supposed to directly modify the database like this but it has half-worked and I was wondering if there's a way to execute a method or a module so all nodes will have their field filled, or if I should erase all contents of the table and use db_update() or node_save() to do the job.

thanks in advance


texts: Can't add instance of custom field type to entity

texts:
I have a custom field type that I'm trying to add to a custom fieldable entity. The entity works fine and I've added other fields to it, my problem is when I go to add an instance of my field to the entity, I get the following SQL error:

  There was a problem creating field Authors: Exception thrown while
  performing a schema update.
  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL, PRIMARY KEY (entity_id, deleted, delta, langcode), INDEX bundle' at line 9: CREATE TABLE {myentity__field_myfield} ( bundle VARCHAR(128) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance', deleted TINYINT NOT NULL DEFAULT 0 COMMENT 'A boolean indicating whether this data item has been deleted', entity_id INT unsigned NOT NULL COMMENT 'The entity id this data is attached to', revision_id INT unsigned NOT NULL COMMENT 'The entity revision id this data is attached to', langcode VARCHAR(32) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT 'The language code for this data item.', delta INT unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields', field_myfield_target_uid INT unsigned NOT NULL COMMENT 'The user ID of the author', field_myfield_affiliation NOT NULL, PRIMARY KEY (entity_id, deleted, delta, langcode), INDEX bundle (bundle), INDEX revision_id (revision_id)  ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT 'Data storage for myentity field field_myfield.'; Array ( )

I've replaced my entity with myentity and my custom field type with myfield for the above. My schema definition for my field type is as follows:

/**
 * {@inheritdoc}
 */
public static function schema(FieldStorageDefinitionInterface
$field_definition) {

  $columns = [
    // List the values that the field will save. This
    // field will only save a single value, 'value'
    'target_uid' => [
      'type' => 'int',
      'not null' => true,
      'unsigned' => true,
      'description' => "The user ID of the author"
    ],
    'affiliation' => [
      'type' => 'varchar',
      'size' => 255,
      'not null' => true
    ]
  ];

  $schema = [
    'columns' => $columns,
    // 'indexes' => [
    //   'target_uid'
    // ],
    // 'foreign keys' => [
    //   'target_uid'
    // ],
  ];

  return $schema;
}

I've looked at other core field types for guidance but I can't see where I'm going wrong.