texts: How to debug Drush command with xdebug in vscode?

texts:
I reviewed a lot of articles (including Can Xdebug be triggered by Drush commands?) about debugging Drush commands in PHPStorm with settings xdebug.idekey. They suggested export XDEBUG_CONFIG="idekey=session_name" or set xdebug.idekey in the php configuration file. I can confirm that I have set xdebug.idekey in php.ini

The weird thing is that vscode php debug extension does not provide any setting for idekey. It is very different from other IDE. But I still can use the vscode to debug with Drupal site.

Any one knows how I can make xdebug working on Drush command?

Here is my xdebug configuration extracted by command php -i | grep xdebug. All these values are the same as the output from phpinfo()

/etc/php/5.6/cli/conf.d/20-xdebug.ini,
xdebug
xdebug support => enabled
IDE Key => sublime.xdebug
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
xdebug.collect_params => 0 => 0
xdebug.collect_return => Off => Off
xdebug.collect_vars => Off => Off
xdebug.coverage_enable => On => On
xdebug.default_enable => On => On
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.extended_info => On => On
xdebug.file_link_format => no value => no value
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.halt_level => 0 => 0
xdebug.idekey => sublime.xdebug => sublime.xdebug
xdebug.max_nesting_level => 256 => 256
xdebug.max_stack_frames => -1 => -1
xdebug.overload_var_dump => 2 => 2
xdebug.profiler_aggregate => Off => Off
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => Off => Off
xdebug.profiler_enable_trigger => Off => Off
xdebug.profiler_enable_trigger_value => no value => no value
xdebug.profiler_output_dir => /tmp => /tmp
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.remote_addr_header => no value => no value
xdebug.remote_autostart => Off => Off
xdebug.remote_connect_back => On => On
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => localhost => localhost
xdebug.remote_log => /tmp/xdebug.log => /tmp/xdebug.log
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
xdebug.scream => Off => Off
xdebug.show_error_trace => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => Off => Off
xdebug.trace_enable_trigger => Off => Off
xdebug.trace_enable_trigger_value => no value => no value
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => /tmp => /tmp
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3

Settings value of PHP debug extension

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "php",
            "name": "Listen for XDebug",
            "request": "launch",
            "localSourceRoot": "${workspaceRoot}/docroot",
            "serverSourceRoot": "/var/www/Sites/independent01-dev/docroot",
            "port": 9000
        },
    }
}


texts: How to fix errors when installing varbase with Composer?

texts:
I'm using Drupal 8 and I'm trying to install the varbase distribution from the command line, on Windows with Acquia Dev Desktop.

The steps I did are:

Disable opcache
Check composer -V  >>> result
Run composer create-project Vardot/varbase-build:^8.4.06 %1 --no-dev --ignore-platform-reqs

This is causing the following error:

  Installing vardot/varbase (8.4.06): Downloading (100%)
  Writing lock file
  Generating autoload files
  PHP Parse error:  syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\www\tmp_var\vendor\drupal-composer\drupal-scaffold\src\PrestissimoFileFetcher.php on line 34
  Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\www\tmp_var\vendor\drupal-composer\drupal-scaffold\src\PrestissimoFileFetcher.php on line 34

I installed composor on windows Url:
https://getcomposer.org/download/

(This is besided the compososer which is included in Acuia Desktop Version 2)

C:\www>composer self-update
You are already using composer version 1.5.1 (stable channel).

Then I exectuted commando:

composer create-project Vardot/varbase-project:^8.4.07 varbaseyellowbird --no-dev >> installlog.txt

After running it my project drupal folder was not looking good so I runned it again.


texts: Edit meta tags per entity via field or entity property?

texts:
Is there a way in Drupal 8 to override the global meta tags at the entity (node) level when adding or editing content? I thought the option previously existed in 7.x, but I am not seeing it in 8.x.

If not, is there a way to alter the meta tags when preprocessing a node to inject them based on node fields in code?


texts:
I'm trying to run a serious of updates on Drupal.

However, I'm seeing to be running into the following error:

Unresolved dependency   File Entity (Version >7.x-2.0 required)
Media requires this module and version. Currently using File Entity version 2.0-beta2

Where would the directory structure be so I can update the file entity and do the updates.


texts: Can I add to an existing Entity schema from my own custom module

texts:
I'm extending a the Quiz module; by having taking extra data regarding the test .   For this I have a custom module that redirects using a custom form .

It all works fine but as its only a single value I'd like to just add it to the existing 'Quiz result' entity.  I know how to do this by hacking the 'contrib' module
OPEN 'quiz.install' and adding it to the $schema['quiz_node_results'] array.

Once its added here I can then see it in Views as needed.  But obviously this solution isn't good enough.  Is there a way to add to an existing Entity schema from my own custom module; rather making a separate table in SQL for this info.

I've tried hook_schema_alter as well, but can't seem to get that to work either.

Here's what I had in my my_module.install file

 function my_module_schema_alter() {
  $schema = array();
  // Create the quiz node results table
  $schema['quiz_node_results']['fields']['time_taken'] = array(
    'type' => 'int',
    'size' => '10',
    'not null' => TRUE,
    'default' => 0,
    'description' => 'Stores the user inputted estimated time.',
  );
}

function my_module_install() {
  $ret = array();
  $schema['quiz_node_results'] = array();
  rcni_saq_extended_schema_alter($schema);
   foreach ($schema['quiz_node_results']['fields'] as $name => $spec) {
    db_add_field($ret, 'quiz_node_results', $name, $spec);
  }
}

Many thanks for any help.


texts:
I inherited a Drupal site recently that I'm having a bit of trouble with. Essentially, I need to hide a menu in a mobile view, but still remain visible on a desktop. So far, I've added this to my css file:

/* Mobile Hide */
    @media (max-width: 991px) {
        .mobile-only {
          display:none !important;
          }

          .desktop-only {
            display:block !important;
          }
        }

Using Chrome, when I apply the "mobile-only" class to the div I'm trying to disappear, it works perfectly. The only problem is I have no idea how to actually apply this class to the real div in the server's files. How can I apply this to an actual file in Drupal?

Thank you.


texts:
I have a content type and sort theme in a page with views as a table
And now, I want when users go to this page, they can see just the posts that the made them.
see just post made by their-self.
what filter should I do?
How?


texts: How to display events in chronological order?

texts:
I am new in Drupal and I want to display events in chronological order by start date of the event.

My current setup is that the latest added event is showing.

Here is a screenprint of the View I created so far:

Any suggestions?


texts: Anonymous user not redirected to log in page which was previously working

texts:
When any anonymous user clicks on Checkout button then he/she will be　redirected to log in page. Previously this functionality was working very fine. But then I was researching on it, I unchecked the permission of "Access checkout" for anonymous user. I checked what happens doing that. Afterwards I reverted the change.

But from that time I'm not able to redirect anonymous user to log in page. Also site does not show the Checkout button without logging in.

I will try by adding rules. But how come this functionality broke down?

Is there any solution for it?


texts: Is it possible to allow users with Javascript disabled to cancel their accounts?

texts:
I have a Drupal 7 site where users have permission to cancel their accounts.  Most users are able to cancel their accounts without trouble, but some users (at least some of whom do not have Javascript enabled because they are on extremely old mobile phones, etc.) are unable to cancel their account because doing so takes them to an AJAX batch processing page that doesn't work on their devices.

Is there an alternate way to allow such users to cancel their accounts, or am I stuck doing this manually?

EDIT: I realized that the cause of this issue is my use of the code in this solution to remove the e-mail confirmation requirement, so this issue probably only affects my site.


texts:
I created a view with a "Custom text" field and want to get this field programmatically in Drupal 8.

I have:

$view = Views::getView('my_view');
$view->execute();
foreach($view->result as $row){
    $node = Node::load($row->nid);
    // Get here the view custom field with label "An example view field".
}

The $row field doesn't have the fields, nor the $node.

A screenshot of the view:

I now have:

$customField = $view->field['nothing'];

customField is an instance of Drupal\views\Plugin\views\field\Custom.

dpm($customField->render($row));

This returns class Drupal\views\Render\ViewsRenderPipelineMarkup with protectecd string with the same markup: {{ title }} test.

Thanks,


texts: How to solve “Query failed” error in drush sql-sync output 2?

texts:
I have the exact same problem as in How to solve "Query failed" error in drush sql-sync output?, exact same output. That user found the answer as the password in settings.php was wrong, but my password is correct and it still doesn't work. Can anyone please help?

drush sql-query --strict=0 --file=/tmp/mob_20191203_224013.sql.gz --file-delete --uri=mob --root=/home/fc/1/de/mob/web -vvv
 [preflight] Config paths: /home/fc/1/de/mob/vendor/drush/drush/drush.yml,/home/fc/1/de/mob/drush/drush.yml
 [preflight] Alias paths: /home/fc/1/de/mob/web/drush/sites,/home/fc/1/de/mob/drush/sites
 [preflight] Commandfile search paths: /home/fc/1/de/mob/vendor/drush/drush/src,/home/fc/1/de/mob/drush
 [bootstrap] Starting bootstrap to max [0.04 sec, 8.57 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalRoot() [0.04 sec, 8.57 MB]
 [bootstrap] Change working directory to /home/fc/1/de/mob/web [0.04 sec, 8.57 MB]
 [bootstrap] Initialized Drupal 8.7.10 root directory at /home/fc/1/de/mob/web [0.04 sec, 8.76 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalSite() [0.04 sec, 9.06 MB]
 [bootstrap] Initialized Drupal site mob at sites/default [0.04 sec, 9.29 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.04 sec, 9.29 MB]
 [debug] Add service modifier [0.04 sec, 9.45 MB]
 [info] Executing: command -v mysql [0.05 sec, 9.91 MB]
 [info] Executing: mysql --defaults-file=/tmp/drush_IsKDek --database=mob --host=localhost --silent -A < /tmp/mob_20191203_224013.sql.gz [0.05 sec, 9.96 MB]

In SqlCommands.php line 199:

  [Exception]
  Query failed.

/tmp/mob_20191203_224013.sql.gz exists, /tmp/drush_IsKDek does not
Drush is 9.7.1, Mint 19.2, alias

loc:
  root: /home/fc/1/de/mob/web
  uri: mob
  options:
    command-specific:
      sql-sync:
        sanitize: true
        structure-tables:
          common:
            - cache_advagg
            - cache_bootstrap
            - cache_config
            - cache_container
            - cache_data
            - cache_default
            - cache_discovery
            - cache_dynamic_page_cache
            - cache_entity
            - cache_menu
            - cache_page
            - cache_render
            - cache_toolbar
            - watchdog
            - history
            - sessions
    os: Linux
  paths:
    dump-dir: /tmp
    files: sites/default/files


texts: Entityform send email to entity referenced node email

texts:
I have a content type "Business" which has a field "Business Email".

I have an entity form with an Entity Reference field that allows a user to select mutliple businesses, leave a message and click send.

I need to send an email to the "Business Email" field of all referenced Businsess in the submission.

I have set up a Rule to react "After saving a new entityform submission" which checks "Enity has field:Business Email", and then sets up a send mail, but I am having trouble actually getting the value for business email and looping through it. Has anyone achieved something like that that can lend a hand?


texts: User cannot edit one custom profile field other users can

texts:
Drupal 7.

The profile field is a very simple long text, text area, filtered html.
When I try to edit it in my own regular user (no admin roles) page, with the standard permissions everyone has, I can do it no problem.
A specific user has reported that he cannot do it at all. A message is displayed that his permissions are insufficient instead of the editable text area.
A third user was kind enough to click his own edit button and has no problem just like me.

I double checked permissions (field permissions module is in use) and they seem absolutely ok. I tried to peek inside the database but don't see anything suspicious (I may not be looking in the right tables).


texts: How to load an include file from Drupal's include folder?

texts:
I am experiencing a problem with the GlobalRedirect module in that it seems like it is not loading the locale.inc which it relies upon. I tried using the module_load_include function but did not work as locale.inc isn't apart of a module.

I know I can use:

include(DRUPAL_ROOT."/includes/locale.inc");

Is there a Drupal specific function call to load include files for Drupal? I am curious if there is.

Thanks


texts: How to get formatted total amount programmatically?

texts:
I want to get the formatted total amount of my cart items.

I used the following code

$order = commerce_cart_order_load($user->uid);
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$line_items = $wrapper->commerce_line_items;
$total = commerce_line_items_total($line_items);

It returns me $4000 instead of $40.00.

On shoping cart page it display $40.00. How can I get the price in this format?

I want this in commerce way not some custom php like number_format etc.


texts: Can Webforms include the URL they were submitted from in their emails?

texts:
I have a bunch of webforms in blocks on taxonomy pages.
It would be helpful for the recipient of the resulting emails to know what taxonomy page the user was on at the time they wrote their query.
Do I use the %get token in a hidden field? And if so then what [key] value returns the full (pathauto) url?
Webforms can only use %get[key] and %post[key] for non-authenticated users.


texts: How can I pass parameters to a Services endpoint?

texts:
I have installed Drupal 7 and enabled Services in it. I have also created an endpoint /api/v2/ and in resources, I have allowed nodes to be listed as JSON.

I have sent a GET request using browser or POSTMAN to /api/v2/node then I am getting following results.

 [
 {
 nid: "3143",
 vid: "3932",
 type: "event_calendar",
 language: "en",
 title: "EVENTS STILL APPEAR ON FRONT PAGE WHEN EVENT HAS ENDED - with or w     ithout an END DATE ",
 uid: "139",
 status: "1",
 created: "1560282811",
 changed: "1560282922",
 comment: "1",
 promote: "0",
 sticky: "0",
 tnid: "0",
 translate: "0",
 uuid: "",
 uri: "http://..../api/v2/node/3143"
 },
...
 ]`

If I send a request to http://..../api/v2/node/[nid] then I am getting an individual record of that node.
Now I want to get post parameters to the endpoint. For example, I want to get all nodes with type = event_calendar.

I have tried posting parameters like http://..../api/v2/node?type=event_calendar but unfortunately, It is still showing list of all nodes. I have tried thing using POSTMAN and browser.


texts: Perfomance question about share (or not) fields CCK in lots of content types

texts:
I am working in Drupal 6.x.  I have approximately 50 content types.  All content types have common fields CCK.  Each content type has approximately 25 fields.  Is better share the common fields CCK or is better to make the fields for each content type?

These content types are used for views.

In terms of performance, resource consumption, what is the better option?

Thanks to all for your ideas.


texts: Show prices excluding Tax/VAT but calculate and display only on checkout

texts:
In case of B2B store I need to display all prices without VAT taxes. But taxes must be shown on cart and during checkout process. What's the good way for this?

I use commerce_vat.


texts: I have a vocabulary with a field "legacy_id" which is a primary key another related system.  I am building a routine to update the data in the drupal system based on changes in the related system.  Other then hitting the DB directly, is there a way to retrieve the tid or the entire term from the field?


texts: Create a new node when a field is added to a node

texts: How can a element (say an image) that is entered as a field (when creating a new node), also be created as a separate new node at the same time (either through copying the image or by referencing it)?


texts:
So I'm struggling again with my sorted links: there are many many links (node type) which also contain the field "link_category".

I collect them all in a view and sort them by "link_category".

It works like a charm and looks like this:

link 1 | Category 1
link 2 | Category 1
link 3 | Category 1
link 1 | Category 2
link 2 | Category 2
link 3 | Category 2
link 4 | Category 2
link 1 | Category 3
link 2 | Category 3
link 3 | Category 3

but now I want to hide the link_category on each item and instead, show one title above them like:

*Category 1:

link 1
link 2
link 3

*Category 2:

link 1
link 2
link 3
link 4

*Category 3:

link 1
link 2
link 3

Is it somehow possible with Views or do I need some extra modules?


texts: Media library does not display grid properly when accessed as non-admin user

texts:
Using Drupal core 9.1.7
Theme: Eclipse multipurpose theme

Enable Media and Media library modules
Add a field to a content type as Media (Entity reference)
Setup form display to show this field as Media library
Add content using this field
Click Add media

Media will be displayed as grid. However, if you are adding content as a non-admin, existing media items are displayed one item in a row, while when the content is added as admin, the items are displayed nicely formatted in a grid.
Inspected in a browser console errors are reported when logged on as non-admin user. No errors are reported when logged on as admin user.
Console error:
Uncaught Error: Syntax error, unrecognized expression: #
at Function.se.error (jquery.min.js?v=3.5.1:2)
at se.tokenize (jquery.min.js?v=3.5.1:2)
at se.select (jquery.min.js?v=3.5.1:2)
at Function.se [as find] (jquery.min.js?v=3.5.1:2)
at S.fn.init.find (jquery.min.js?v=3.5.1:2)
at new S.fn.init (jquery.min.js?v=3.5.1:2)
at S (jquery.min.js?v=3.5.1:2)
at c (bootstrap.min.js?v=1.x:6)
at HTMLAnchorElement. (bootstrap.min.js?v=1.x:6)
at Function.each (jquery.min.js?v=3.5.1:2)


texts: How to check if an entity object has been modified before saving it?

texts:
When calling the save() method on an entity, the timestamp value for last modified is always updated, regardless of whether the entity was actually modified.

Is there a way to check if an entity object has actually been modified before saving it?

I haven't seen any flags, similar to is_new, but perhaps there is a method or PHP function that can be used?

Simple example:

$entity_type = 'my_entity';
$entity_id = 1;
$entity = entity_load_single($entity_type, $entity_id);

// With EMW.
$entity_wrapper = entity_metadata_wrapper($entity_type, $entity);
$entity_wrapper->save();

// Witout EMW.
$entity->save();

In these cases the modified property of the entity is still updated even though nothing was actually changed.


texts: How to include any view into the same panel

texts:
To reduce duplicated panel pages for every view I want to display, I'd like to re-use the same panel (the same layout) for several views. The problem is that I can't find how to include ANY view in panel where view is passed by argument or URL. There are only particular Views Content panes available but this results in creating as much panel pages with URLs as there are views. And any changes in "common" panel content elements must be made for every panel page which is overkill.

There is analogue solution for nodes - predefined panel "node_view" ("/node/%node") which can display ANY node's content passed in URL. There's an element "Node content" which does that.
Is there similar solution for views? Thanks in advance!


texts: How to use language-translation functions on custom-coded menu for translation module compatibility?

texts:
I created a custom menu that uses menu_load_links() and menu_link_load() to get permission, path, and title info to output a menu. It currently outputs a very simple HTML list of links without any theme or translation function wrappers, and I'm trying to apply the correct wrappers to make it theme- and module-compatible.

This site is currently single-language but in the future it will be in multiple languages. Which translation functions wrappers do I need for my links? There's t(), st(), and get_t() (that I am aware of).

Are there other translate functions that I should be using that I am not aware of?

And is it sufficient to apply t() to the displayed link title only, or does it need to be applied to, say, the path or alias or anything?

Here's the code:

$foreshadow_menu_items = menu_load_links('menu-program-menu');
print('
');
foreach ($foreshadow_menu_items as $foreshadow_menu_item) {
    $foreshadow_menu_item_info = menu_link_load($foreshadow_menu_item['mlid']);
    $foreshadow_menu_item_access = $foreshadow_menu_item_info['access'];
    $foreshadow_menu_path = $foreshadow_menu_item['link_path'];
    print ('
');
    if ($foreshadow_menu_item_access == 1){
        print("");
    }
    else{
        print("
");
    }
    echo "$foreshadow_menu_item[link_title]\n";
    if ($foreshadow_menu_item_access == 1){
        print('');
    }
    else{
        print("
");
    }
    print ('
');
}
print("
");

I especially don't understand the instruction on t(),

  You should never use t() to translate variables, such as calling t($text); unless the text that the variable holds has been passed through t() elsewhere (e.g., $text is one of several translated literal strings in an array).

How is this not a catch-22?


texts: An error upon trying to execute Drupal Console

texts:
I installed Drupal 8 into on my localhost, working under Windows 7 with OpenServer.
After it I tried to install Drupal Console using Composer.
Namely, this way

composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader

It installed without errors.
But when I'm trying to execute Drupal Console (with command "drupal"), there is an error on the console:

Fatal error: Cannot use Drupal\Console\Core\Bootstrap\DrupalConsoleCore as DrupalConsoleCore because the name is already in use in D:\OpenServer\domains\palomniki.local\vendor\drupal\console\src\Bootstrap\Drupal.php on line 11

Could you clarify me, how to solve this problem ?

Frankly speaking, I managed to find answers of the error, where they advice to reinstall Drupal Console, but I don't know what they means. I tried to do remove this package, then to reinstall it, but I wasn't able to fix the error.


texts: Is it possible to implement theme preprocessor on specific template in drupal 8?

texts: What I am here trying to achieve is simple. I want to change the default drupal "submitted by" field to only render day and date but not the time when the node was created. To do so I want to preprocess the field which is being evoked by field.html.twig. But apparently, I don't want to run the preprocess on every field by using hook suggestion "field". Hence i created the specific template "field--default--node--node-submitted-by--blogs.html.twig". Now I want to implement theme preprocessor on this specific template. Can achieve on based on template suggestions or not?If so how?


texts: Submit the multi-step from at step 2 instead of last step

texts:
I have a form with 5 steps. We have used "simple multistep module".
Whole idea is, when any user start filling new form, only first 2 tabs should be visible. Then, if user wish to provide any updates on same form, first 2 tabs data will be pre-filled (yet editable) and all 5 tabs will be visible.
In form alter, for new form, i have disabled rest of the 3 tabs fields using
$form["field_some__id"]["#access"] = false;

I also disabled the tabs using following code
unset($form['#fieldgroups']["group_some__group_id3"]);

My function looks like as follows
function MODULE_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  if($form_id == "SOME_FORM_ID") {

    $form["field_some__id"]["#access"] = false;

    $form["field_some__id1"]["#access"] = false;
    $form["field_some__id2"]["#access"] = false;
    $form["field_some__id3"]["#access"] = false;

    $form['actions']['preview']['#access'] = false;

    unset($form['#fieldgroups']["group_some__group_id3"]);
    unset($form['#fieldgroups']["group_some__group_id4"]);
    unset($form['#fieldgroups']["group_some__group_id5"]);

    if($form_state->get('multistep_controller')->getCurrentStep() == "2") {
      /*Here i want to submit the form instead of going to next steps*/
    }

  }

I tried https://www.drupal.org/forum/support/module-development-and-code-questions/2019-06-20/skip-a-step-in-simple-multistep solution, but after clicking on step 2 "Next", blank form appears with "Submit" button and after pressing that button form gets submitted.


texts:
In page.tpl.php, I add some static images by using :

$bolo = path_to_theme() . '/images/bolo.gif';
....
<img src="<?php print $bolo ?>" alt="bolo" width="71" height="125">

How I can do the same by using a preprocess function (like theme_image() for example) in template.php and calling the (image)variable in page.tpl.php ?
It seems easy, but I can't perform it.
Thanks

Bolo


texts: Form not showing in administration menu in Drupal6

texts:
I'm trying to create a simple form with a textfield in the administration panel but I get the message "You do not have any administrative items"

Here is the code inside my ptm_autocomplete.module:

function ptm_autocomplete_menu() {
  $items['admin/prestum/autocomplete'] = array(
    'title' => 'Autocomplete',
    'description' => 'Autocomplete',
    'page_callback' => 'drupal_get_form',
    'page arguments' => array('ptm_autocomplete_form', array(), array()),
    'access arguments' => array('access administration pages'),
  );

  return $items;
}

function ptm_autocomplete_form(&$form_state, $unused, $form_values) {
  $form = array();

  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Color'),
    '#description' => t('Color'),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );

  return $form;
}

Any ideas what might be wrong?


texts: Add conditional javascript from CDN (external library)

texts:
I know it has been discussed here several times, but:

Is there a way to include conditional JS from CDN in the head section?

My goal is to somehow use drupal_add_js, external. That will stick in the head area, even if I move scripts to the bottom of the page. It is about html5shiv and respond.js

The classic way to add js was discussed here and here. So what I've managed so far is to bring

<?php
function THEMENAME_preprocess_html(&$variables) {
    drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.js', 'external');
    drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js', 'external');
}

The problem is conditional. One way to add conditional elements, with drupal_add_js. I know how to load local conditional js, using a variable I'm creaing in template.php, like so:

<?php
$html5shiv = array(
    '#tag' => 'script',
    '#attributes' => array(
        'src' => file_create_url(drupal_get_path('theme', 'THEMENAME') . '/js/html5shiv.js'),
    ),
    '#prefix' => '<!--[if lte IE 9]>',
    '#suffix' => '</script><![endif]-->'
);
drupal_add_html_head($html5shiv, 'html5shiv');

But this will only put the conditional JS even before the meta title element and I need this to be loaded at the end of my  section, JUST BEFORE my scripts loaded from theme.info (scripts[] = js/main.js). And of course, this will load local JS, not external.

Any ideas?


texts:
I duplicated a view before making changes, but it didn't save and I'd changed most of the view settings before I realised I was working on the original.
How can I recreate the standard taxonomy view?
I am using Drupal 9, if that makes a difference.


texts:
I tried to set up SASS as part of an Omega 4 theme on a VPS server, but I'm now drowning in Ruby permissions and versioning issues. It's causing far more sysadmin type work than a CSS generator is worth for this project.

The Omega 4 docs repeatedly state that SASS is helpful but not essential to Omega 4 and that you can simply write CSS the old-fashioned way, which is what I intend to do - but they don't say anything about how to stop Omega trying (and failing) to apply SASS all the time.

How can I completely disable the SASS element of Omega 4?

I can't find anything relevant in the theme settings. I've tried simply removing / renaming the sass folder in my subtheme and clearing caches, but I'm still getting Ruby / SASS related errors that look like this:

  Error: File to import not found or unreadable: singularitygs.

I want it to completely stop trying to do anything related to SASS.

From reading around, it sounds like it's common to have a Drupal production server run Omega 4 with no SASS, and for people to have SASS on their development server then upload the CSS output to production when they're happy with it. Sounds sensible. But how what I can't find is, how do they stop the production server from trying to run SASS and access all that Ruby stuff all the time?


texts:
I want to add two files, CSS and JavaScript, to be used in a Drupal site,  without linking them to the used theme. I can add these with Bash.
touch /var/www/html/example.com/{css.css,js.js}
chmod 644 /var/www/html/example.com/{css.css,js.js}

I need to include both files.
Sometimes I create small sites without modifying the theme at all, but I still need some minor CSS/JavaScript changes that don't justify creating a sub-theme. I wouldn't mind creating two "quick" and "global" files directly on the Drupal directory just for that.
Can this be done in Drupal 8.5.6?


texts: How to change filed type from integer to string

texts:
using D8. I have a field field_number just in one bundle (a node content type that I called law). Now I found that I need to change the field type; it needs to be of type string and not integer.

I wonder if there is a quick/easy way of using migrate or something similar

I remember that time ago I used VBO in D7 but seems that the PHP option is not available in the D8 version of the module. Like in this case:  https://drupal.stackexchange.com/a/28349/5422

I'll like to try using a hook_update_n on a custom module like in this example: How do I change a field type? but not sure if the the new field (as is created programatically) will be easily available for views and other modules and I don't want to end with a mess.


texts: How to get nodes created on current using Views and Drupal 8

texts: How can I display records that were created on the current date using views. I have used the now value on the created date filter but the records are not showing. I think its because now also includes the the current time. Please Help?


texts:
I have been thrown into a Drupal 6 environment, helping a client whose site has been running terribly for some time now. Among other issues, they had a ton of traffic and were serving it all locally, so we aim to implement a CDN.

Our CDN of choice is Incapsula, who operate much like Cloudflare if you're familiar with them. At their most basic, they can cache static content. Should be simple.

What I'm finding is that when Incapsula's caching is enabled, the cache never updates. If you go through the public address to the site, you will see old content. It's not just old images and CSS, entire pages will be missing if they are added after the cache is enabled. If you bypass the proxy, you see the correct content. Manually clearing the cache from within the Incapsula control panel does not resolve the problem, I can only do that by actually disabling the cache. Of course, while it is enabled, the site flies!

Complicating this, they have Boost installed and enabled. I am new to Drupal, newer to Boost, and I am attempting to understand how the caching works but have not made much progress. Are there specific settings within Boost that might affect this? It feels like a header is misconfigured. Any thoughts and advice are appreciated!


texts:
When I use the this code; <?php $block = module_invoke('locale', 'block_view', 'language'); print $block['content']; ?>, I get the following output. But I'd like to add another class to ul.

EN

RU


texts:
I have added my own content type with many fields to enter, I want to hide some fields when adding a content according to radio button selection.
I explain, in the add content page, i have two radio buttons (inside/outside) and inside is selected by default and some fields are hidden, when user select outside, some fields will be hidden and the fields accorded to outside will be shown to user to fill them.
How to do this ?


texts: how to reset taxonomy term ids after deleting all term from all vocabularies

texts:
after deleting all terms from all vocabularies we are still left with the next available ID of last created term

is there any module that does such a thing ?
or one has to go manually and set the auto increment ?
are there are any side effects with using manual way?


texts:
i want to make a complicated tabs block for terms  (i usually views and quick tabs for this and it works great) . in this block i want a main tabs bar when i click on one of it it shows the content that have that term or any of its chlidren term, also i want a second tabs bar to show, if the main term have any children term and put in that bar the lev.1 children for the main term ,so if i click on it it shows the term's content and any of its children term content to ,i hope i described it well ,  check the image for more understanding

my question is : is that possible using views or any other modules or should i create my own module -which i allready started creating but its taking a long time - ??

thanks in advance


texts: Multiple Relations and Contextual Filters in a Translated View

texts:
I have a View designed to filter down translated content (of type "Asks, Actions, and Updates") using three arguments:
1) country
2) year
3) month.

I have translated the content type and content, all three vocabularies and terms, and the View.

I want the URL to be readable, so the View has a relationship to the three vocabularies. I also have four "Translation language" filters, one for the content, which is being shown, and one each for the three vocabularies.

I also have three contextual filters that use the taxonomy "Name" and filter correctly in English with the following
contextual filters entered into the preview:

burkina-faso/2018/july

However, for some reason, the contextual filters do not work for French with these parameters:

burkina-faso/2018/juillet

Interestingly, the following does work

burkina-faso/2018/all

but when the last argument is 'juillet' (which is the French translation), it acts as through the name does not validate (no query shows in the preview section).

Why is this happening, and what can I do to have these filters work in both languages?

Here are images of the set-up of the third contextual filter:


texts:
How do I add a NUMBER field to my content type?
A NUMBER field means a serial id similar to auto incremented primary key on a DB table.
I wanna use a unique NUMBER in view related to my content.


texts: Changing the layout of user profile edit page

texts:
I am working on a website based on Drupal Commons.
It uses Commons Profile Module to add extra fields to add user information.

I want to accomplish two tasks:

Change the layout of User Profile edit page i.e. : mysite/user/%user/edit.
Where do I make the changes. Should I create a new *.tpl.php file and if so, then where?
I want to fetch the User Information Fields added by the Commons Profile Module to the edit form.

Please provide a solution in which both these issues are taken care of.


texts: Commerce: adding +/- buttons to the Quantity field

texts:
I am working on a site that uses the Commerce module for a web store. The design specifies that the user's cart overview page should allow them to increase and decrease the quantity of a particular item using plus/minus buttons. However, as far as I can see the only option for a quantity field is a bare text field (in commerce/config/line-items/product/fields). I've searched for solutions online, but apart from the Commerce Extra module (which is in alpha, and does not allow for vertically-stacked buttons as per the design) I'm coming up blank.

Is there an 'accepted' way to add these buttons to the quantity field, or am I missing something in my configuration?


texts: Autofocus on select or textfield works on and off

texts:
I have set autofocus on my form element as follows:
$form['product']['widget']['#attributes']['autofocus'] = TRUE;

The element is autofocused intermittently, if I refresh page 10 times it works for like only 5 times. And it never works if I open the form initially, until I refresh the page. What could be wrong?
Th product select element is inside a fieldset which is inside a vertical tab. I notice that if I take it outside the vertical tab, then autofocus always works, but once inside the vertical tab, then it works on and off.


texts: Where is webforms template info stored in the database

texts: I'm using webforms in Drupal 8.  I have migrated an old database over but need to overwrite the correct webforms table to restore a webform template I created on a previous site.  Can you tell me which table in the database the template webform fields are stored please?


texts: Where do I set the conditional e-mail recipients?

texts:
I need to set-up an auto response email/and submission page specifically for only three countries out of a list of many.

So, if someone selects (is from) country x, y or z, they see a different confirmation page and the form results are sent to two specific, unique addresses.

Otherwise, the form does what it is doing now which is displaying the confirmation message under Webform Settings.

I'm not sure about the conditional email recipients. Do I edit the actual "Country" form component and check E-mail a submission copy? But then, where do I actually enter something like AU|thisperson@example.com?

If I 'configure' the actual form, when I click "country" under the Conditional e-mail recipients, no additional fields appear for me to enter AU|thisperson@example.com

So I'm confused as to where to put the logic for the form to send a unique response page as well as specific email addresses only when a user from either x,y,z country?

I'm not fluent in php but thought I would need to put a comparison of the [country_code] and if it was either x/y/z then....what? Is there a specific call to a mail function? And as to adding the text for this secondary submission confirmation, I've no idea where to put that.


texts:
I have a field "Organisation name" on the user profile. The users fills the organization he is working for when creating his profile.

On the profile display page, I would like to add a custom display to this field. When some one hovers over this field, I would like to show some information about the organization from dbpedia/wikipedia.

I would like to know how i can add a custom display to a field on the user profile. Can i do this with the Display Suite module ?


texts: How to add a field to Views table output with hook_views_pre_render?

texts:
I have a view displaying node titles formatted as a table. In a custom module I'm using hook_views_pre_execute to do do a table join and add a field to the views query. (I cannot use a regular relationship in Views to accomplish the join, because it has to be a RIGHT JOIN).

When I inspect the resulting view object with dpm($view) in hook_views_pre_render, I can see that the objects in $view->result contain the string values of the node_title, nid, and field_myfield_value (where field_myfield_value is added via the custom module).

But how do I actually display field_myfield_value in the view? And more specifically, how do I make it a column of the table?


texts:
I have a view which is rendered as a table, the last column is labeled "actions" which I display both the "Edit" and "Delete" links accordingly.

I need to implement a few more custom operations, I found this as a starting point:

Custom entity operation links

Here is what I have thus far:

module.module

<?php
  function module_views_api() {
    return array(
      'api' => 3,
      'path' => drupal_get_path('module', 'module') . '/views',
    );
  }

module.info

files[] = views/module.views.inc
files[] = views/module_handler_print.inc

module.views.inc

<?php

  function module_views_data() {
    $data = array();
    $data['node']['print'] = array(
      'title' => t('Print link'),
      'help' => t('Provide a simple link to print the content.'),
      'field' => array(
        'handler' => 'module_handler_print',
      ),
    );

    return $data;
  }

module_handler_print.inc

<?php
  class views_handler_field_node_link_print extends views_handler_field_node_link {

    function render_link($node, $values) {
      // Ensure user has access to edit this node.
      if (!node_access('update', $node)) {
        return;
      }

      $this->options['alter']['make_link'] = TRUE;
      $this->options['alter']['path'] = "node/$node->nid/print";
      $this->options['alter']['query'] = drupal_get_destination();

      $text = !empty($this->options['text']) ? $this->options['text'] : t('print');

      return $text;
    }

  }

I can see the option when adding the field to VIEWS but when I select it I get the error:

  Configure field: Broken/missing handler

Any ideas???


texts: Access denied or format unknown on field in Services Views

texts:
Installed the following modules in Drupal 7

Services
Services Views

When creating new services view, I am facing the following issue.

nid and title fields shown correctly, but other fields including body and custom fields showing the following error. "Access denied or format unknown on field."

The preview shows as below:

array (
  0 =>
  stdClass::__set_state(array(
     'nid' => '47',
     'title' => 'World Cup Stadiums',
     'publish_date' =>
    array (
      'error' => 'Access denied or format unknown on field.',
    ),
  )),
  1 =>
  stdClass::__set_state(array(
     'nid' => '49',
     'title' => 'Ladies Fencing Tournament 2014',
     'publish_date' =>
    array (
      'error' => 'Access denied or format unknown on field.',
    ),
  )),
  2 =>
  stdClass::__set_state(array(
     'nid' => '48',
     'title' => 'FIfa World Cup',
     'publish_date' =>
    array (
      'error' => 'Access denied or format unknown on field.',
    ),
  )),
  3 =>
  stdClass::__set_state(array(
     'nid' => '46',
     'title' => 'Fifa World Cup Title',
     'publish_date' =>
    array (
      'error' => 'Access denied or format unknown on field.',
    ),
  )),
)


texts: How do I filter a view within a view based on an Enity Reference field when NID is not in the URL of the container view's page?

texts:
I have 2 content types: Artist & Artwork

Artwork contains an Entity reference field pointing to a single Artist called "Artist"

I have 2 views:

Artist Detail - A page view showing a single artist using title (artist's name) as contextual filter so url is human readable. eg. myexhibit/pablo-picasso
All artwork by an artist - A block view listing art by a specific artist using the "Artist" Entity reference field as contextual filter

I want to embed view #2 into the header of view #1 so that art tied to that artist appears on the Artist Detail page view.

I can get it to work if I change my filter on #1 to filter by Node ID and then pass that Contextual Filter to the embedded view. But I don't really want my URL to be myexhibit/213.

Is there a way to pass the node ID of the node matching the argument "pablo-picasso" to the embedded view?
Or a way to get the embedded view's contextual filter to work using a node title rather than the NID referenced in the Entity Reference field?


texts:
I am using Drupal 8 Beta 14 and I want to edit the node object in teaser view mode. As hook_node_view is removed in Drupal 8. What's the alternative hook or some other way that I can use to edit the node? Is it hook_ENTITY_TYPE_view or hook_entity_view or some other thing?

Thank you.


texts:
$term = Term::load($_tid);
$term->field_league_id = 'ID value';
$term->Save();

I am updating the terms by the code above but it's not working. Create the term by term->Save() is works normally. Everyone had experienced with that please help.

Updated:

$term = Term::load($_tid);
$term->field_league_id->setValue($league_id);
$term->Save();

This solution is not working, it's throwing:

  Call to a member function setValue() on a non-object in..

At the top, I declared ref. already.

use Drupal\taxonomy\Entity\Term;

The code for create new taxonomy is working fine, but not for updating.

$term = Term::create([
            'name' => $league->caption,
            'vid' => 'league',
            'field_league_id' => $league_id,
            'field_league_code' => $league->league,
            'field_league_year' => $league->year,
            'field_league_numberofteams' => $league->numberOfTeams,
        ]);

        $term->Save();


texts: How to change the place of a block or region based on url path?

texts:
I have a menu block and it will be displayed on all pages, but I need to change the placing of it. On certain pages (dependent on path) I need to display it above the main content, while on other pages I need to place it below the content.
I am experimenting with the context module and I was able to put the block above the content, but then on these pages, the menu shows BOTH above and below the content.

I have a solution in mind, but there must be a better way: I can set up two regions, one above and one below the content, then put the menu block in the region below the content, and set up a context to put the menu in the above region AND hide the below region. This could work, though I think there should be a more elegant way.


texts: How to set the default for checkboxes element

texts:
I'm trying to set the default of a checkboxes list in the form_alter_hook.

$form['average'] = array(
  '#type' => 'checkboxes',
  '#options' => array('a','b','c'),
  '#default_value' => array('a'),
  '#title' => t('The average vote is more than'),
  );

I'm expecting 'a' to be checked, that it never seems to happen. I'm using better exposed filters, but I doubt that would make a difference?


texts:
I know that I can set default images for content types, but for my page, I would like to only display the default image for one particular view and not the other ones.

It would also be nice if the image is automatically displayed in the proper image style just like a regular image. Therefore it seems that I can't use "no results behavior" since there, I would have to specify the full html myself.

So can I somehow tell drupal 7 to use a default image for a view in case there is no image for an article such that it does not affect any other views?


texts: How to set paths for menu items in hierarchy to make it work with Superfish

texts:
I'm confused about what to do with the menu items whose sole function is 'to be parent' i.e. no content attached to them. One way I wanted to solve this is to set the path to <front> for those items. But then subitems just won't fly out anymore.

Similarly, if I set the path of a parent item to the node that belongs to a child item, the parent just totally disappears out of the menu, leave alone that there would be a child to pop out of.


texts: Links continue to point to live server - Drupal Live to localhost

texts:
I have inherited a Drupal 6 site to maintain.

I am new to Drupal so there is an element of learning as I go.

I have encountered a strange issue after attempting to set up a test site on my local machine.

All my links on my local site continue to point to the live server. So any menus, login buttons etc all point towards live site.

Steps I have taken:

checked settings.php to ensure that $base_url is set to
"http://localhost:456"
checked settings.php to ensure that MySQL settings are correct
Taken an SQL dump of the entire local database and searched for any
references to live site URL
deleted all the local cache data from database
Checked various blocks to ensure that there was no hard coding of
links
Disabled language support as that does use separate URLS for each
language

I am at a total loss as to where to go from here. I can navigate through the site locally by replacing the url in the address bar to point to the local site, and I have even managed to change the local theme so I can see which version of teh site Im on. The fact that I could do this means that the database is set up correctly.

Totally stumped as to where to go from here. Any takers??


texts: Translate configuration values in custom webform handler

texts:
I created a Custom Webform Handler, which uses the email and name data from the form input to subscribe the user to a newsletter service through the vendors API.
Ich created a configuration form with this handler, where I can input the API key and the mailing list of the newsletter service.
This all works well up until the point where I want to translate the webform to a different language. I need to have a different configuration for the mailing list in German than in English.
I checked the code of the handlers that come with the webform module, but I can't figure out, how to define, which configuration field values should be translated. I need to have the newsletter_list form element to be translated.
Can anyone help?
This is my shortened code
<?php
/**
  * @file custom_webform_handler/src/Plugin/WebformHandler/NewsletterWebformHandler.php
  */
namespace Drupal\custom_webform_handler\Plugin\WebformHandler;

use Drupal\webform\Plugin\WebformHandlerBase;

// ...
/**
 * ´Newsletter Webform handler.
 *
 * @WebformHandler(
 *   id = "newsletter",
 *   label = @Translation("Newsletter Subscription"),
 *   category = @Translation("Subscription"),
 *   description = @Translation("Subscribe to Newsletter"),
 *   cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
 *   results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_IGNORED,
 *   submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_REQUIRED,
 * )
 */

class NewsletterWebformHandler extends WebformHandlerBase
{
  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'newsletter_apikey' => '',
      'newsletter_list' => '',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form['newsletter'] = [
      '#type' => 'fieldset',
      '#title' => $this->t('Newsletter settings'),
    ];
    $form['newsletter']['newsletter_apikey'] = [
      '#type' => 'textfield',
      '#title' => $this->t('API key'),
      '#default_value' => $this->configuration['newsletter_apikey'],
      '#required' => TRUE,
    ];
    $form['newsletter']['newsletter_list'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Mailing List'),
      '#default_value' => $this->configuration['newsletter_list'],
      '#required' => TRUE,
    ];

    return $this->setSettingsParents($form);

  }
  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form, $form_state);
    // ...
  }

// ...
}

I read that I need to have a schema for doing this, so I tried adding one, but it didn't change anything
# file custom_webform_handler/config/schema/custom_webform_handler.schema.yml
webform.handler.newsletter:
  type: mapping
  label: 'Newsletter'
  mapping:
    newsletter_list:
      label: 'Mailing List'
      type: string

Edit
To make it more clear:
I created a Handler that has this configuration form

The connection settings are the ones that need to be translated
When I go to the translation page of my webform, I can translate the Email-Handler settings, but not my custom Newsletter Subscription handler settings


texts: Why is there a module for version 9 of core?

texts:
I checked this module page, it have the download option for Drupal 9 version. Why is Drupal 9 is launched when there isn't an official stable Drupal 8 release? Is there anything wrong with Drupal 8?

Why did they ignore Drupal 8? I also found the Drupal 9 development snapshot release.


texts: Adding/ Editing list of people with photos

texts:
I've created a content type called 'Cast'. Authorized users need to have ability to create a different list of cast members, add/edit their info, upload photo. Essentially, it's a team roster problem.

I'm having hard time figuring out how to solve this problem? What module is most suitable for this purpose?


texts: how to setting drupal i18n translation module not to translate system menu I don't want?

texts:
In my site I am using drupal7 i18n module to translate to Burmese language. But my problem is I don't like drupal to translate system fields that does not need to translate because translation is totally wrong and might confuse for user, so it is better for user to leave these as English such as system field and something like that. When I click Burmese language in language switcher block, all for content fields, sitemap navigation, content types fields and product fields are changed to burmese, but translation is really really confusing for me and also for customer. So I am thinking that it is easy for me and customer if not system translated, and I will have to manually interpret the fields and taxonomy that I want to local user to understand.

Any suggestion is greatly appreciated.

Thanks

Highlights in above two images are really misunderstanding and that doesn't need for i18n module to interpret.


texts:
I have a view for search results.

I want to add the "rating" widget, but I cant find a way how to include it in the Search API fields. => The views cant make the relationship.
Is it possible ?

Clarification:
The view is not the "ordinary" type -> displaying contents, but it is displaying "Search index".
I am able to display fields that are defined by the Search API settings page, but I am unable to add relationships, for example Rate Widget (Vote Results module).

As a solution, I embedded another view as a field. That seems to work, but I am asking if there is another approach out there.


texts: How do I set up user's "Favorite Tags" and "Ignored Tags" tag subscriptions?

texts:
This website shows user-specific "Favorite Tags" and "Ignored Tags" listing tags the user subscribed to. Based on these subscription lists, content is being sorted in "views".

How do I let the users pick favorite tags?
How do I create a "favorite tags" block like it is done on this site?
How do I up Views to prioritize content assigned to subscribed tags?
Is it possible to use a Flags-like module to assign flags to taxonomy terms?


texts: Why Calling the theme path in a multinlingual site adds a language prefix?

texts:
In my template whenever I call the path to my theme in a particular language it adds a language suffix dir like mysite.com/fr/sites/all/themes/mytheme while I'm expecting a path without a prefix (e.g. mysite.com/sites/all/themes/mytheme).

I'm use drupal_get_path() or path_to_theme().

How can I ensure I get the right path in my template?


texts: Add attribute to all textboxes in the site

texts: The question is simple , in my theme I want to apply an attribute to all textboxes in whole forms . I know how to add an attribute to an specific element in drupal using hook_form_alter , but it is too time consuming for lots of elements , so I'm eager to see if there is an easier way to do that.Any suggestion?


texts: Date picker libraries are missing in specific page

texts:
I am adding jquery date picker feature using date field in profile edit page it is working fine .

But when i am adding same jquery datepicker in custom module, datepicker function is not working.

After seeing view page source i have found these three libraries are including in profile edit page where date picker is working.

<link rel="stylesheet" href="/core/assets/vendor/jquery.ui/themes/base/datepicker.css?q7wdca" media="all" />
<script src="/core/assets/vendor/jquery.ui/ui/widgets/datepicker-min.js?v=1.12.1"></script>
<script src="/core/modules/locale/locale.datepicker.js?v=8.6.15"></script>

But i am not able to figure out why these libraries are not including in custom form page.


texts: How can I show anonymous users their own content?

texts:
I've tried to reach this with views and https://www.drupal.org/project/session_node_access and https://www.drupal.org/project/views_extras with no luck.

Any suggestions?


texts:
I wanted to block a bulk amount of users of my site. I was thinking to do it by firing a sql query and turning off the status field of users directory.

So is it safe to fire such sql or is there any otherfunction which does that?

My site is still in drupal 6.

Tks
Vil


texts:
I'm using Time Field to make a field in my event content type for the begin and endtime in of the event.
I know that when you outpout the time field via views, you can output it as 24h notation, which works fine. But I want to output the time using php in a tpl file
using the row object.
So I have php code in my views tpl file that says:

    <?php $uur  = $row->field_field_evenement_uur[0]['rendered']['#time']['value_formatted'];
          $uur .= ' - ';
          $uur .= $row->field_field_evenement_uur[0]['rendered']['#time']['value2_formatted'];
?>

First thing that came to mind of course was go to admin/structure/types/manage/my_content_type/fields/my_time_field and set the field formatting to 24h notation. It simply looks though like it's not part of the configuration.

Then I debugged my $row output in my view to discover this other way to get a rawer sort of value for the time. This way I would write code like:

$row->field_field_evenement_uur[0]['raw']['value'];

So that would output the time value like 51600. I've been looking for some formatter functions that I could wrap around this value and get me a 24hour notation, even from php.net but it's all seeming like it has to do with the date(); function.


texts: How do I create a jump link to a paragraph item?

texts:
I'm trying to create a jump link to the paragraph item. This is what I tried

create a compact display of the page just printing out a title and short summary.
using the advanced text formatter I created a link in this index

It takes me to the paragraph page. I figure that I can use a token in the advanced text formatter to create an anchor link from the compact display to the detailed display. Then I have to work out how to add the anchor to the detailed display.

How do I create a link with the delta as the anchor e.g. /abc/test.html#1?
How do i create the anchor on the detailed display?


texts: Move upload file field automatically after editing its container node

texts:
Suppose you have 'Book' content type with three fields:
- class (content taxonomy field)
- category (content taxnonomy field)
- book file ( file upload)

the filefield path settings for 'book file' :
class/category

so when changing one of them, the file directory should be changed automatically ( without re upload it again).

Any suggestions?


texts: How do I get the vote result in Vote API?

texts:
I have installed the rate module, and found out that the votes associated to a node are stored in the votingapi_vote table.
Is there a function to use to get the sum of all the votes for a node?


texts: What is the easiest way to prepare separate admin panels for creating users of different roles/profiles e.g. 'add editor', 'add client', 'add subscriber' etc. that will have separate set of fields?


texts: Send notification E-Mail to x when x’s content is commented

texts: How to notify an author of a node, when her content is commented by another user on Drupal 7?


texts: Trying to make a custom region disappear upon user login, then reappear when user logs out

texts:
I've looked everywhere for an answer to my problem, but can't find one. My goal is to collapse/force a custom region on my website to disappear when a user logs in, and then have it reappear when the user logs out.  Or, if it's not possible to collapse a region, to replace the region with an empty region that, through CSS, I have styled to display with zero height. Basically, I'm trying to make a custom region disappear upon user login, and then make it so the region reappears when the user logs out.

The reason for this is I'm putting the final touches on transforming the login block on my website so that instead of appearing in the sidebar, it appears as a horizontal login bar. I'm 90% of the way there. I created a custom region at the very top of the page to house the bar, and the bar kind of looks like the horizontal login bar you see on Facebook. But in reformatting the login block using CSS, I was only able to achieve the look I wanted by forcing the "Forgot your password?" and "Create a new account" links not to appear (otherwise, the links would reside between the password field and the "Log in" button, which looked weird).

But that left me with no login help links. To try to resolve this problem, I created a new region directly under the "username" and "password" fields to house the "Forgot your password?" and "Create a new account" links, which displays really nicely. But, of course, whenever someone logs in, those links remain on the screen, which is obviously weird.

I need to figure out a way to make the new region disappear when the user logs in, and to reappear when the user logs out. Also, I want the other regions in the header directly below the two new custom regions to move up once the region disappears so that there's not a gaping hole in the space where the region used to be. I'm pretty new to PHP, so what I've tried may be way wrong, but this is what I attempted, which didn't work -- it's the option of trying to swap out the region with the links with the empty region when a user logs in:

     <?php
        if(isset($username) == false):
        print render($page['nameofregion1']);
        else: ?>

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

where the CSS for 'region2style' is set to "height: 0px" to give it zero height. My suspicion is that I'm misusing the variable $user here, among other errors, but I can't seem to figure out what variable holds username info in Drupal. I'm sure there's a more elegant way of doing this, and if someone could point me in the right direction, I'd really appreciate it. Thank you.


texts: Is this block safe from code injection exploit?

texts:
Thanks good people here, I have create a simple module which generate two blocks as follows:

function myblockmodule_block_info(){
    $block['myadblocks'] = array(
        'info' => t('My first ad blcoks'),
        'cache' =>  DRUPAL_CACHE_GLOBAL,
    );

    $block['myadblocks2'] = array(
        'info' => t('My second ad blcoks'),
        'cache' =>  DRUPAL_CACHE_GLOBAL,
    );
    return $block;
}

/**
 * Define what our block is going to look like.
 * Implements hook_block_view().
 */
function myblockmodule_block_view($block_key){
    $block = array();

    if($block_key == 'myadblocks'){ //We only want to define the content of OUR block
        //This is the title of the block.
        $block['subject'] = '';

        //Define the block content.
        $block['content'] = '<script>some ad js comes here</script>';
    }
    elseif ($block_key == 'myadblocks2') {
      $block['subject'] = '';
      $block['content'] = '<script>some other ad js</script>';
    }

    return $block;
}

My intention is to user these blocks instead of my current blocks that were volnurable to to script injection.

However, I am not sure the new module-based blocks will be more secure than the old admin-generated blocks. So appreciate your critical review of the module above.


texts: Display all taxonomy terms's ids associated with nodes in a view

texts:
I need to display the term ids of each node under its title in a view.

I can do similar display by adding node: title and node: all taxonomy terms. But I just want to display tid's instead of term names.

My view result should look like this:

title: Node title 1

tids: 1, 2, 4

title: Node title 2

tids: 3, 5, 6

Is there a way to alter or add a views field for this?

Also in general, how are fields that is available to the views constructed?


texts:
Date field having multiple values. Need to format the output.

{% for item in items %}
<div{{ attributes }}>{{ item.content|date(format="F j, Y") }}</div>
{% endfor %}

item.content showing the date as updated. But not able to format the result. Got the below error,

  TypeError: DateTime::__construct() expects parameter 1 to be string,
  array given in...

Please suggest on this issue.


texts:
i have set up entity translation and everything is working. except for menus. I have a translation set defined for a menu item in "main-menu" and have 2 languages set up for a menu item. However, now both show up in the main menu regardless of which language i am in.

any clues?

its possible my custom menu tree may have something to do with it?

in page.tpl >

$pid = variable_get('menu_main_links_source', 'main-menu');
$tree = menu_tree($pid);
$tree = str_replace(' class="menu"', '', $tree);
$main_menu = drupal_render($tree);
print $main_menu;


texts: Cache images in custom module without caching entire render array

texts:
I created a module that generates a slide show. This isn't using views, I'm manually loading nodes that contain images and placing them inside a render array in a block plugin. When running an audit in chrome I noticed a message

  The following resources are explicitly non-cacheable.

Then it lists all the images present in that slideshow. After reading this I understand that you can cache render arrays, but I still need it to be dynamic, so that the slideshow updates everytime a node is added. Also different slideshows are shown to different users so I need that dynamic as well.

Is there a way to cache only the images in a render array?


texts: Prepopulate custom fields during checkout with data from user account

texts:
I have installed Drupal Commerce in an existing site and I am currently trying to figure out how to prepopulate fields during the checkout process. I use the Commerce Extra Adress Popuplate module to fetch the address information from the user account, but how do I do this exact same thing with other custom fields? For instance I have a custom Client number field in the user account that I really would need to prepopulate to the checkout form.

I have read a bunch of other post on this subject (for instance Populating fields from the User entity during a Commerce checkout, but I haven't found a solution that seems to do exactly what I am looing for.

EDITED: to be more specific, I have created a new Customer Profile using the Customer Profile Type UI module. It contains one field so far, the client number field.
How can I fetch the current user's value from the same field in the User account, during checkout?

EDITED AGAIN:
With rules I have tried using this setup:

{ "rules_kopiera_kundnummer_fran_anvandaren" : {
    "LABEL" : "Kopiera kundnummer fr\u00e5n anv\u00e4ndaren",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : { "commerce_order_insert" : [] },
    "DO" : [
      { "data_set" : {
          "data" : [ "commerce-order:owner:field-kundnummer" ],
          "value" : [ "site:current-user:field-kundnummer" ]
        }
      }
    ]   } }

But the current client number is not copied into the field in question.
Any ideas?


texts: How can I programatically add the default AJAX throbber to a form submit?

texts:
I'm trying to add the AJAX throbber in core to a form submit button, specifically the Private Message module new message page.

Here is my code:

function MYMODULE_form_privatemsg_new_alter(&$form, &$form_state, $form_id) {
  $form['actions']['submit']['#ajax'] = array(
'callback' => 'MYMODULE_submit_throbber_callback',
  );
}

function MYMODULE_submit_throbber_callback($form, $form_state) {
  return;
}

Here's what I have done so far.

First, I looked at the Page Throbber module for ideas, but this does everything in hook_init(), and it doesn't use the throbber included in core.  If possible, I want to avoid replicating what is already in core for a single form.

Next, I looked in the Examples module, specifically the AJAX example that includes an AJAX submit example.  However, this is for adding a callback to do something else, but all I want to do is get the pager, which appears to happen automatically if you add any kind of callback.

So I added a dummy callback that just returns.  This gives me a throbber, but it breaks the submit functionality of the form.  How do I get the throbber without breaking the form submit?


texts:
I am developing a site using drupal. I need to create a template file for a specific page.
For instance this is my site url http://www.dev.com. I created a basic page called documents which URL path settings alias is docs. So what I want to do is that whenever the user clicks on http://www.dev.com/docs drupal should use a specific template file. For that matter I create a tpl file called page--docs.tpl.php and put it inside my theme folder. However drupal seems not loading that file.

PLease assist me if I am missing something.


texts: buy one get one free Ubercart discount module?

texts:
Can I use some module to make offers in ubercart
I have to make an offer of 2x1 type (buy one, get one free)
or buy 2 and get 1 free type of offers


texts: Is this possible to allow creating nodes only for Administrator via interface but for others in custom code?

texts:
As author of my content type I can choose any user (current user, even anonymous).

Nodes will created programmatically, so:

$node->uid = $current_user->uid;

However I want to allow access to node/add/custom_type (node form) only for Administrator or even block for everyone.

I am no totally sure that Drupal checks permissions before node_save(), so that's why I am asking.


texts: Are there any modules where you can import H2Database data into drupal 7 as nodes?

texts: I'm working with the java h2 database engine and there is data that i want to query/import everyday. Is there a module or how would I go about importing such data into drupal 7 as nodes?


texts:
I'm using StateAPI to store some variables that shouldn't be exported as configurations.

These values are stored in the database, in the key_value table.

Is this a "secure" table? Are there tasks (cache-clear or other) that could automatically remove values from this table?

Is it a good idea to create a custom form to let users to set some states?
They could be simple strings, or url, and I think that create nodes for this information is too "heavy".


texts:
I'm aware of how to change the number of nodes displayed on the front page. My question is whether there is a variable in Drupal, or a way of calculating the numbers of nodes displayed per page of front page content?

I've got a block module that prints out information according to the nodes that are being rendered in the main content area of the front page, so it needs a list of the nodes. If there is an array of nodes that can be accessed that would also work, but I can't find information on that, so I've been trying to calculate the items per page, but merely dividing the total number of front page nodes divided by the number of pages gives inconsistent results of course.

I could of course hardcode the number, but I'd prefer a programatic way for determining this value.


texts: I can't seem to get a Language Selector to appear on my page.html.twig (or in a block). I must be doing something wrong, I can perfectly translate my content by I can't switch language (unless I change the URL myself).


texts: How do I change the global site url when serving Drupal from behind a reverse proxy?

texts:
I want the site name to be the FQDN instead of the machine's internal name (ie: localhost), especially in tokens.
I'd like to be able to change the value once (like say in an env var) so it shows up any time the site's url needs to be used, say in automated emails.

aggravating factor: we're using IIS7


texts: Adding JS and CSS Dynamically to Override Theme

texts:
In Drupal 7 I'm trying to add JavaScript and CSS to dynamically modify the content in a theme. I've spent a good amount of time going over the Drupal documentation, several Drupal books, and the questions/answers on here. I'm trying to pull it all together, but I'm not sure how close I am and was hoping to get some feedback/help. What I have done so far:

(1) Created a CSS file with the code below called knitr.css and put it in the css folder

pre .operator,

pre .number {
 color: rgb(0, 0, 205);
}

pre .string {
 color: rgb(3, 106, 7);
}

(2) Created a JS file with the code below called jquery.knitr.js and put it in the js folder (note, to save space I have removed the js code)

var hljs=new function()
hljs.initHighlightingOnLoad();

 })(jQuery);

(3) Added the following code into the preprocess_node function of the template.php file. Important: responsive and page need to be changed to your theme name and the machine name for your content, respectively.

if ($variables['view_mode'] == 'full') {
$node =& $variables['node'];
if ($node->type == 'page') {
$path = drupal_get_path('theme', 'responsive');
drupal_add_css($path . '/css/knitr.css');
drupal_add_js($path . '/js/jquery.knitr.js', array('type' => 'file',
'scope' =>  'header'));
 }
}

(4) Placed the follwong in the basic content page with as full HTML text format

1 + 2

## [1] 3

Expected output:

I expect the output on the page to look something like the following at this point. The JavaScript and the CSS should be changing the font color of 1+2 to blue (wasn't sure how to change color for example below). I'm getting no errors from what I've done above, but it is not implementing as expected.

1 + 2
## [1] 3


texts: context of view page doesn't show reaction block

texts:
So, I'm trying to have a block show up when my page has a specific page view, and to do so I use the context module.

To make sure my context works, I added a class to the html. It does show up.

But, when i add a block reaction, the desired block never shows up.

However when I use path as a context it does. Problem is, path doesn't cut it for me.

So what do I need to do to get my block to display when the context is a view page.


texts: How to specify a permission as an access argument?

texts:
As I understand for a menu access argument I must specify a permission.

So, let say there is a permission for "Profile: Create new content" that is enabled for authenticated users, and I would like to use this as my menu access check.

This is how I put it in my menu callback?

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

  $items['play'] = array(
    'title' => 'Play',
    'page callback' => 'play',
    'access arguments' => array('Profile: Create new content'),
    'type' => MENU_CALLBACK
  );

  return $items;
}

This does not work though, so how do I get the permission name used by the system?


texts: Adding custom jQuery code on drupal 7 theme

texts:
I'm trying to add some custom jquery code to my theme. I used the code exemple below :

(function($) {
Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {

    //code starts
    $("body").click(function() {
      alert("Hello World");
    });
    //code ends

  }
};
})(jQuery);

The jquery file is loaded with the script but nothing happens on my page, any help ?


texts: How to set different pathauto patterns for same content type, using organic groups data?

texts:
I have a site using Organic Groups.  I would like to have the News content type use one pathauto pattern for News pages that are part of an organic group such as "group/[node:og_group_ref]/news/[node:title]" but when not in an organic group use "news/[node:created]/[node:title]".

Is this possible without having to write custom PHP token code?  If not, I guess I could create a clone of the News content type called Lab News to use just to have a different pathauto pattern.


texts: How to properly use a JS library that inserts content into existing DIV?

texts:
As with many JS libs i need an existing DIV for the lib to insert its content. I am trying to use the Chart.js library to inset a chart on a custom drupalgap page.

I eventually discovered the menu item page handlers and did this:

items['qleva_start_auth'] = {
  title: 'Home Auth',
  page_callback: 'qleva_start_auth',
  pageshow: 'qleva_start_auth_show',
};

in my hook_menu.

qleva_start_auth now only has the required empty DOM element:

function qleva_start_auth() {
  var content = {};
  content['my_stuff'] = {
    markup: '<canvas id="myChart" width="100" height="100"></canvas>'
  };
  return content;
}

and the pageshow callback has the code to set up the chart.

This seems to work great except that my chart is now on every page; added to the bottom of the content for that page.

What am i doing wrong?


texts: Stuck developing a new library module for "vminpoly". "Drupal.behaviors" confusion

texts:
I think this could be really useful to the masses. I've so far not found a alternative. If you know of one, please do advise.

My use case is having a banner with a height of 85% of the viewport. The new vh, vw and vmin length units in CSS are great for this. Except they don't work in all browsers and devices.

The vminpoly library looks like a great solution. At window resize time, it generates CSS code for the 'px' equivalents and appends it in a 'style' element at the end of the 'head' element. The generated code respects media queries.

On their demo the JS part of the source code, in the footer, looks like this:

<script type="text/javascript">
      if (!Array.prototype.filter)
      {
        Array.prototype.filter = function(fun /*, thisp*/)
        {
          var len = this.length;
          if (typeof fun != "function")
            throw new TypeError();

          var res = new Array();
          var thisp = arguments[1];
          for (var i = 0; i < len; i++)
          {
            if (i in this)
            {
              var val = this[i]; // in case fun mutates this
              if (fun.call(thisp, val, i, this))
                res.push(val);
            }
          }

          return res;
        };
      }
    </script>
    <script src="tokenizer.js"></script>
    <script src="parser.js"></script>
    <script src="vminpoly.js"></script>

So being as there isn't much to the module and in the interest of being complete, here are my files:

vminpoly.info

name = Vminpoly
description = Adds the vminpoly javascript plugin. It adds support to allow the use of vw,vh/vmin units in your theme.
core = 7.x
dependencies[] = libraries

vminpoly.module

<?php

/**
 * Implements hook_libraries_info().
 */
function vminpoly_libraries_info() {
  $libraries = array();
  $libraries['vminpoly'] = array(
    'name' => 'Vminpoly',
    'vendor url' => 'https://github.com/saabi/vminpoly',
    'download url' => 'https://github.com/saabi/vminpoly',
    'version callback' => 'short_circuit_version',
    'files' => array(
      'js' => array(
        'tokenizer.js',
        'parser.js',
        'vminpoly.js',
      ),
    ),
  );

  return $libraries;
}

/**
* Short-circuit the version argument.
*/
function short_circuit_version() {
  return TRUE;
}

/**
* Load all files
*/
drupal_add_js('if (!Array.prototype.filter) { Array.prototype.filter = function(fun /*, thisp*/) { var len = this.length; if (typeof fun != "function") throw new TypeError(); var res = new Array(); var thisp = arguments[1]; for (var i = 0; i < len; i++) { if (i in this) { var val = this[i]; if (fun.call(thisp, val, i, this)) res.push(val); } } return res; }; }', array('type' => 'inline'));
$name = 'vminpoly';
libraries_load($name);

I'm sure this will be of help to others, maybe even you.

The question is what is wrong with it. I'm pretty confident (famous last words) that everything is as it should be, except the vminpolydrupal.js file. I'm sure its my lack of understanding when it comes to behaviours and tbh JS generally. I feel as though "context" needs to be added to their code snippet somewhere.

I'm out of my comfort zone and learning. Please help...


texts: How do I programmatically copy an existing Field to another Entity?

texts:
I want to add two new fields to the Commerce Discount entity --- an image and a long text. And I want these to be visible through Views.

I was going to use this code to add the fields:

http://www.monarchdigital.com/blog/2013-08-09/programmatically-creating-fields-drupal-7

But, I was thinking that there are already two fields attached to Node Bundles that do exactly what I want. All I really need to do is -copy- that field information to the Commerce Discount entity Bundles.

So I was thinking that this might do the trick, but I'm not

function() my_module_update_7000() {
  // copy field info from existing entity
  $field_name = 'field_page_banner';
  $field = field_info_field($field_name)
  field_create_field($field);

// copy field instance from existing entity
  $field_instance = field_info_instance('node', 'field_page_banner', 'page')

// ???? will this screw up the data in any existing bundles?
  $field_instance['entity_type'] = 'commerce_discount',
  $field_instance['bundle'] = array('order_discount', 'product_discount'),

field_create_instance($field_instance);
}

Can someone look at this and let me know if I'm on the right track here? I'm not clear on how to assign the field to the new Bundle without 'un-assigning' it from the existing Bundles (if that makes sense.)
Is there anything else I need to do to make these fields available to add to existing Views?
Is there anything else I need to do to make these fields available to users when editing Commerce Discounts?


texts: How should I render the tpl of module at theme

texts:
I create a module and mymodule.module file like this:

function mymodule_menu(){
    $items['mymodule/list']=array(
        'type'=>MENU_CALLBACK,
        'page callback'=>'mymodule_list_view',
    );
    return $items;
}

function mymodule_list_view(){
    theme('list_view');
}

function mymodule_theme($existing, $type, $theme, $path){
    return array(
        'list_view'=>array(
            'template'=>'mymodule_list',
            'type'=>'theme_engins',
        ),
    );
}

then I create templates file: mymodule_list.tpl.php

And I create a theme and create templates file: page--mymodule.tpl.php. Now when I access /mymodule/list, it will use page--mymodule.tpl.php to render the page.

My question is: how should I write page--mymodule.tpl.php to display the content in mymodule_list.tpl.php?


texts:
I am trying to get my first module to work which is supposed to render an array in his own template file.

1) I got an array of variables and return it in my controller

        array(
        '#theme' => 'myTheme',
        '#test_var' => $this->t('Test Value'),
        '#array' => array('key'=>$myArray),
        );

2) in my .module I declare the hook_theme()

  return array(
'myTheme' => array(
  'variables' => array(
    'test_var' => '',
    'array' => array(),
    ),
),

);

3) Then I would like to print the variables
I am sure I missing something, and if I'm missing basic knowledge please let me know. I'm sure something is  wrong in the hook_theme since I don't know how to iterate my array in the template file.

test_var: {{ test_var }}

{{ array }}

If somebody could point me in the right direction, that would be nice :)

edit: the "Test Value" is rendering just fine


texts:
Is there any other way to create more secure link in a drupal_set_message??

$loglink = l("bla bla", 'admin/config/services/blabla');
  drupal_set_message(t("You should not have empty or the default fields in $loglink. You have to fill your own information."), 'error');


texts: How to use WYSIWYG editor with structured content in Drupal 7?

texts:
I am wandering what would be the best strategy to combine a WYSIWYG editor and structured content. I want the user to be able to add the following in the body field with a WYSIWYG editor:

Images
Links to other nodes
Links to, for example, YouTube

I also want to be able to have these added images, links etc. as structured content (to put them out in a view, for example.)

Is there a solution for this? I think the best way would be to use entity reference module for that.


texts: What is the best way to handle post data in drupal?

texts: What function I need to implement to handle simple post data when I submit a form?


texts: EVA + Corresponding Node References + Views + Sort by Order of Appearance on Page Node

texts:
Thanks in advance for any help or suggestions with this problem. I will try to be as clear as possible. Basically, what I want to do is customize my Page node "County" to show a table of "Organization" nodes (along with their contact information) referenced in the county node.

So what I have done is to use the EVA + Corresponding Node References modules to create a table view on my county page. The problem is that I cannot figure out how to configure Views so it will list the organizations in the same order that I referenced them in the county node --  See screenshot http://www.diigo.com/item/image/16wo5/0jmw. As you can see from my screenshot I have ordered them first "Org 3" and then "Org 1", but in the views table they are ordered first "Org 1" and then "Org 3".

From reading other posts I suspect that I need to add a relationship in my view but I feel like I have tried almost everything and I still can't get it to sort correctly. Here's a screenshot of my Views admin page -- http://www.diigo.com/item/image/16wo5/x7hr

Thanks again for any help.

-Scott


texts: Working with a checkbox and EntityFieldQuery

texts:
So I have a custom field which is a checkbox and is called 'field_hide_panel'.

The on value is '1' and the off value is '0'. But bare in mind, this field was added later so there are a lot of rows in my database which will not have any field_hide_panel value.

When this checkbox is selected it should be omitted from the results of my query.

I have this line to try to achieve this:

$query->fieldCondition('field_hide_panel','value', '1', '!=');

The problem is, I'm not getting anything returned. I think this is because most of my nodes don't have a 'field_hide_panel' value at all but I still want these returned as my logic says these should still show because field_hide_panel does not equal 1.

Is there any way around this without me having to go through hundreds of nodes and re-save them so they get '0' as the field_hide_panel?


texts: Disable publish and unpublish options in VBO on the main content view for one role

texts:
We have a situation where a user that has a role without permissions to administer nodes is able to bypass that restriction and use the VBO widget to mass-publish or -unpublish nodes on the system content view at /admin/content.

My thought was to unset the publish and unpublish values from the select box definition, but after debugging with hook_form_alter, I discovered I could not see the element in the form definition.

I next tried to look at the view object with hook_view_pre_view, but I don't see it there either?

How can I selective alter the VBO widget? We don't want to get rid of it altogether, but we can't have people without permissions publishing and unpublishing nodes.

Edit: I found this question, but it only explains how to delete those operations altogether, for everyone, which is not what we want. We only want them gone for people who don't have permission to publish or unpublish.


texts: Panels -> Add content in panels gives AJAX HTTP-error

texts:
When I'm trying to add Content to a panel page (just installed Panels), I get this error message:

An AJAX HTTP error occurred.
HTTP Result Code: 400
Debugging information follows.
Path: /panels/ajax/editor/select-content/panel_context%3Apage-panel%3Apage_panel_panel_context/middle
StatusText: Bad Request
ResponseText:
Runtime Error
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: .9em}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a &lt;customErrors&gt; tag within a &quot;web.config&quot; configuration file located in the root directory of the current web application. This &lt;customErrors&gt; tag should then have its &quot;mode&quot; attribute set to &quot;Off&quot;.
&lt;!-- Web.Config Configuration File --&gt;
&lt;configuration&gt;
&lt;system.web&gt;
&lt;customErrors mode=&quot;Off&quot;/&gt;
&lt;/system.web&gt;
&lt;/configuration&gt;
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the &quot;defaultRedirect&quot; attribute of the application&#39;s &lt;customErrors&gt; configuration tag to point to a custom error page URL.
&lt;!-- Web.Config Configuration File --&gt;
&lt;configuration&gt;
&lt;system.web&gt;
&lt;customErrors mode=&quot;RemoteOnly&quot; defaultRedirect=&quot;mycustompage.htm&quot;/&gt;
&lt;/system.web&gt;
&lt;/configuration&gt;

Someone who has a clue? What can it be?


texts:
I've a page showing the users. I wanted to categorized them, so I created roles and I'm grouping all the users according to their role.
Now, I want to have a filter in the view to give the opportunity to the users to select the different types of users, example: employee, student, etc. The view will display the users according to the filter value.

How can I accomplish this?


texts: Using menu tokens (or similar?) to create "invite user link" on OG Group page

texts:
I am new to tokens but was planning to use the menu to token to create a simple menu allowing group administrators to easily invite users without going to the Group administration menu.

The default Organic Groups (7.2x) link for inviting members is: http://www.example.org/group/node/GID/admin/people/invite-users

As the Group ID (GID) is the same as the Node ID (NID) I thought that the [current-page:url:args] would work well. so I created a menu link with the path

group/node/[current-page:url:args]/admin/people/invite-users

Which crashes all group pages and also makes it impossible to delete the link in the menu as "the website suffered a temporary issues". Uninstalling the Menu token modules solves the issue but I am wondering how to make the menu link work as I intended.

For anyone interested in the bug this seem to be a known issue (see: https://www.drupal.org/node/1205086).


texts: How to create a different page.tpl.php for different page, if pathauto is active?

texts:
I am new in drupal 7. I have created a page about us. My url is look like:

http://domain_name/content/about-us

Now I want a different page.tpl.php for this particular page.

Please help how to do this?

Thanks

Prabeen


texts:
I've installed the AJAX Comments module in my Drupal site.

Am unable to find the configuration to remove the reply Link from the comment reply, kindly suggest.

Attaching a screenshot below:


texts: How to add a list of stock and node reference to create the perfect stock of beers?

texts:
I'm creating a Drupal site that is able to follow the stock of your beers.

For beers, I have a Beer Content type wth all info on the beer, it's OK.

Now, for each user, I want to give the possibility to create a list of beer and the number of beer user has in fridge. How can I do that?

I was thinking of making these Content Types:

InStock (fields : int + node reference to beer).
MyBeers (fields : node reference to InStock).

But with that, user has to create one InStock for each beer and then after that create one MyBeers and reference to all it's beers, so it isn't the good approach.

I don't want to make custom module if it's possible.

Ideally in fact, in my perfect works, I can add directly a List of (node reference to beer + int items in stock) into the InStock but I don't know how to do so.


texts: Show or hide fields in view based on a user relationships

texts:
I have a table on my site made with views. I have the User Relationships module installed so users can connect with each other.
I want most of the fields to be visible for all users but there is one field that must only be showed if the author of the content and the logged in user have a relation with each other.

Is this even possible? I have tried different settings.
It is possible with a filter criteria to hide the complete node if the users aren't related. But that is not what I want. It is just one field of that node type that must be hidden if the users aren't related.


texts: File attachments in /files/ disappearing

texts:
I'm having an issue on my site with uploaded file attachments disappearing. As an example, on our blog, we have images uploaded into the blog post with images added by using the file attachment. I've recently found them being deleted from the server resulting in an image placeholder. Yet the record of the file being attached is there and the source code within is correctly pointing.

Does anyone have any suggestions on how to diagnose this?

Our server is hostgator if that makes any difference. I'm not certain it's a Drupal problem.


texts: Contextual Filter not working wiht URL aliases

texts:
I have this issue with contextual filter. I have set the filter so it would get an ID of an article and based on that ID, it would show the name of the author.
The problem is, it doesnt work with URL aliases.
For example, when I put the ID of the node like example.com/node/22, it finds the author. But when I try to put the URL alias like example.com/clanky/something-something-something, it doesnt show anything.
Any idea how can I solve this?
Thank you for any reply.


texts: translate menu item using entity translation

texts:
I am kind of confused and really need some guidance
Is there a way to translate menu items using entity translation?(One item for all languages)
Thanks


texts: Results of a Views display as an array (D7)

texts:
With Views in D6, I was able to get the results of a Views display as an array and work with it using php code embedded in a node.

For example, using this code snippet:

$view = views_get_view('view_name', 1);
$view->set_display('block_1');
$view->preview();
$MyArray = $view->result;

This allowed me to get the results of the 'block_1' view display into the $MyArray array.

However, I'm trying to do the same thing in D7 and all I'm getting is a list of all the nodes in the view I'm calling, and not the results of the view display.

How do I get the results of a view display in code for D7??


texts: Node object doesn't exist when not logged in

texts:
I am trying to use the preprocess_page hook to add some twig variables.

All worked fine, until I logged out. When I'm logged out, the hooks $variables does not contain a node object.

Sample code:

function MYTHEME_preprocess_page(&$variables) {
  $variables['hero_image'] = '';

  if (!empty($variables['node'])) {
    $node = $variables['node']; // if logged in, this is set, logged out, it's not
    // other code here...
  }

}