texts: Domain Access error on module install - ... 'without WWW. prefix'

texts:
I am meticulously trying to follow the directions in the INSTALL.txt file for Domain module. However, after setting up everything as asked in the instructions, I then try to enable the module.  I always get this error:

(Currently using Domain Access The domain string is invalid for www.tourismbuilder.com:

WWW prefix handling: Domains must be registered without the www. prefix.

If you are using drush, please provide the --uri option (e.g. drush en domain
        --uri="http://example.com/optional_subdirectory").)

The error is not very clear. Domains must be registered where without the www. prefix?

What does this mean? Note, I am not using Drush.

EDIT: VirtualHost settings

<VirtualHost 111.68.19.219:80>
    ServerName   tourismbuilder.com
    ServerAlias  *.tourismbuilder.com
    UseCanonicalName Off
    DocumentRoot /var/www/vhosts/tourismbuilder.com/httpdocs
    CustomLog  /var/www/vhosts/tourismbuilder.com/statistics/logs/access_log plesklog
    ErrorLog  /var/www/vhosts/tourismbuilder.com/statistics/logs/error_log
</VirtualHost>


texts:
I am using d7 and views.

I've created a view tpl file specific to my view using the the file name of: views-view-fields--cameras.tpl.php

<?php

foreach ($fields as $id => $field): ?>
<?php
$output = '';
$output .=  $field->label_html;
$output .= '
';
if($field->label_html == 'camera_brand_star:')
{
$output .= $field->wrapper_prefix;
$output .= '
hello
';
$output .= $field->wrapper_suffix;
}
else if($field->label_html == 'camera_price_star')
{
$output .= $field->wrapper_prefix;
$output .= '
'.$field->content.'
';
$output .= $field->wrapper_suffix;
}
else if($field->label_html == 'brand:')
{
$output .= $field->wrapper_prefix;
$output .= '
'.$field->content.'
';
$output .= $field->wrapper_suffix;
}

else
{
$output .= $field->wrapper_prefix;
//$output .= '
'.$field->content.'
';
$output .= $field->wrapper_suffix;
}
$output .= '
';
echo $output;
//echo $field->label_html;
?>
<?php endforeach; ?>

The if conditions are not working at all as its not printing any content. Only it prints the output of     $output .=  $field->label_html;   What am I doing wrong?


texts: Getting the error "$().once is not a function"

texts:
till today noon my site working fine but after that suddenly my site was struck and in error console it give me below error.

  Error: TypeError: $(...).once is not a function Source File: modules/overlay/overlay-child.js?mixmsl on Line: 111.

/**
 * Modify forms depending on their relation to the overlay.
 *
 * By default, forms are assumed to keep the flow in the overlay. Thus their
 * action attribute get a ?render=overlay suffix.
 */
Drupal.overlayChild.behaviors.parseForms = function (context, settings) {
  $('form', context).once('overlay', function () {
    // Obtain the action attribute of the form.
    var action = $(this).attr('action');
    // Keep internal forms in the overlay.
    if (action == undefined || (action.indexOf('http') != 0 && action.indexOf('https') != 0)) {
      action += (action.indexOf('?') > -1 ? '&' : '?') + 'render=overlay';
      $(this).attr('action', action);
    }
    // Submit external forms into a new window.
    else {
      $(this).attr('target', '_new');
    }
  });
};


texts:
I am working on a website which has many Entity forms and some of the Entity form has field collection with few fields in it and it allows multiple items "Unlimited". When you save the node, the data does not save. When you click 'add new item', it also doesn't save the data, it just creates a new set of empty fields and has a 'remove' button.

after pressing submit button the form save all the data apart from data which is in Field collection.

After some research I come to know that Entity forms is not a good option for forms which has more them 100 Fields, because after 100 Fields the form creation become very slow.

one of the Entity forms in website has 180 Fields I am not sure if it is causing the problem.

There is no error message in logs, server error log and Firbug.


texts: How do I print out values from a select field with multiple values

texts:
Currently I have a select field with multiple string values in a custom node. I'm trying to print them out without any html markup.

Currently I am declaring my variable like this:

$categories = $content['field_category'];

And I'm trying to print it like this:

foreach ($categories['und'] as $item) {
    echo $item['value'];
}

But nothing gets printed out. What am I doing wrong?


texts: Move Acquia dev destop sites to another local enviroment

texts:
What would be the easiest way to move all websites from my old Mac to new Mac or Pc that are done in Acquia Dev Desktop ?

Also, downloading new version just overwrites old installation leaving websites in place, or it will create new version of DevDektop where i have to import all sites from old one ?


texts:
I need to know how to remove modules via ftp, i activated some modules, and now im getting constantly errors like

  Fatal error: Call to undefined function views_include() in /home/a7898297/public_html/sites/all/modules/eva/eva.module on line 113

so how can i remove custom modules?


texts:
To prevent spambot making fake user accounts I've installed Spamicide.

I've enabled the module Spamicide (7.x-1.0-beta3) and enabled the field for form_id user_register_form, filled in a Spamicide directory and chose a custom FORM FIELD NAME.

Now when creating a new account I still see a empty field with a description:
"To prevent automated spam submissions leave this field empty". I was expecting that this was hidden by CSS?

Also the directory name I've setup can't be found, is it not created by itself?

The flooding of spambots creating fake accounts is stopped, but the empty field and belonging message looks stupid for real users.

Can you tell me if I did setup something wrong or if this could be an bug?


texts: Display Nodes from Taxonomy Category Term and Parent Terms

texts:
I am using Views and Drupal Commerce but not sure this should matter as all my products are also nodes. I have a taxonomy hierarchy for categories. Example

Exterior Accessories
|_ Top
   |_ Soft Tops
   |_ Hard Tops
|_ Bottoms
   |_ Right Bottoms
   |_ Left Bottoms

I can easily make a page that shows me the Hard Tops if on that location or Soft Tops if at that location. But is what i can not for the life of me  figure out how to do is if I click on TOP I want to see Soft Tops and Hard Tops, and if I click on Exterior Accessories I want it to show products that are from any of the child elements with unlimited depth. So when viewing one of these pages it needs to work like so with the url.

categories/Tops -> Would show soft tops and bottom tops
categories/Soft-Tops -> would show soft tops only
categories/External-Accessories -> Should show everything


texts: How do I store data in entities text-list and field-collections?

texts:
I have retrieved data from an external database using REST.
Now that it is cached in my Drupal 7 site in tables, I need to create new nodes of a specific content type. Works fine for most fields (e.g., text), but...
How do I (using JavaScript) insert data into a text-list field? And, into field-collection fields?


texts:
I have a menu that has a transparent background with the following CSS:

background-color: transparent;
background-color: rgba(113,157,174,0.7);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99dddddd,endColorstr=#99dddddd);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99dddddd,endColorstr=#99dddddd)";

In IE, it doesn't have any color; it is just white. I used an Internet Explorer fix, in which I used the following code:

filter: alpha(Opacity=45);
background-color: #0010A5;
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99dddddd,endColorstr=#99dddddd);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99dddddd,endColorstr=#99dddddd)";

The only thing this did was to make it purple, but it wasn't transparent at all.

![screenshot][1]

I know it is possible because I've seen it done before. What am I doing wrong? How do I fix it?


texts: Block views cause page.tpl.php not to render

texts:
Weird problem -- not sure what is going on. I have a view, which is stored as a block, and that block is shown in the "Content" region of a custom theme which is itself a sub-theme.

The sub-theme implements block.tpl, region.tpl, etc but very minimally:

<?php print $content; ?>

The base theme page.tpl however is static text and requires overloading in any sub-theme -- which I have done quite simply by copying the single line above.

This works on all pages except when I am viewing the View -- in which case if I add any markup to the page.tpl.php the result is blank whiteness :s

The page in question is programmatically generated via hook_menu and a callback which in return invokes the view and passing arguments.

Any ideas???


texts: REST Web Services - Return all fields from Content entity association

texts:
I am currently using the latest release of Drupal 8.0 (downloaded and installed today).

I have two content types.  I have a entity reference on one of the content types that references content from the other content type.

Using both the Views REST Export and the built in REST API I am unable to find a way to return the associated content entity fields.  Currently what gets returned is the target_id as well as a link to the entity.  I am using the hal_json content type.

I have scoured the Drupal docs and I am unable to figure this out.  Any help would be greatly appreciated!


texts: Display field content in views single field template.. STUCK!

texts:
Welcome,

I'm working with Hero slider and views to display slider from nodes in custom type. Where I am now, is:

created node type with fields like title, content, picture and background picture,
created views for dysplay this content, hide all fields, last one is background field, in this field i wrote rewrite twig code do dysplay all fields with some if function to choose prefered slide type and display content right way in every slide,
what I need is make wrap around every li element with slide content, because views filter out  markup, and I can't get slide with responsive background.. life would so much easier with that filter go away.
I work with views-view-field--slider.html.twig that is displayed correct from my template.
I cant display my link to image for background in code:

{{ output -}}

I feel lost with data = row[field.field_alias] tried kint, dump and a lot of various combination of twig code.. looks like I am missing some basics or simple target code to this field. Help me..


texts: How do I access the node's uid in hook_node_access()?

texts:
I have implemented hook_node access so that two users cannot view each other's posts if they do not have the right permission (I implemented the permission in hook_permission). I use a comparison with $node->uid as follows:

 function mymodule_node_access( $node, $op, $account)
 {
   global $user;
   $type = is_string($node) ? $node : $node->type;

   switch($type)
   {
    case "myCustomType":

      if ( ($user->uid != $node->uid) && !user_access("view other's posts"))
       {
              return NODE_ACCESS_DENY;

       }
       break;

   }

}

Everything works fine but I do get the following warning:

  Notice: Trying to get property of non-object in mymodule_node_access().

This is caused by this: $node->uid. Drupal complains that $node is a  not a stdobject (it seems to actually be string containing the node's type). Yet the code still works which I do not understand why.

What is the proper way to access the node's uid from hook_node_access?


texts: Can I programmatically add a string to the translation interface?

texts:
I have used t() to translate a string value. To translate it from the user interface, I first need to view the page on which this string is displayed in a different language. Only then, the string is added to the translate interface.

I want to be able to translate the string before doing that. Can I programmatically add the string to the translation interface?


texts:
There is a function in Drupal 5 (_phptemplate_variables()) that has been deprecated in Drupal 6.
Is there a similar function in Drupal 6?


texts:
I created a custom module and how to add a link along with icon. Basically, I want to add notification icon

backlinks_notifications.index:
  title: 'Notifications'
  parent: system.admin_config_ui (whats the name of that blad navigation bar on top.)
  description: 'Notificationsx'
  url: internal:/home

FYI : Its Admin theme.


texts:
What i want is to have a field called Manufacturer so the user can select the product manufacturer. The way to show the field is an image linking to the Manufacturer page.

example: Product "door handles 0001" has a Manufacturer Audi.

I'm thinking using taxonomy terms with one more field in them (image) but when i import the field just show the name linking to the taxonomy term not the image.

I have see that stackexchange but i can't manage to do it,  the patch is a little outdated..


texts: Displaying specific node type in a page programmatically

texts:
I am a drupal 8 developer, who just needed to migrate drupal 6 site to drupal 7. I migrated all the content and database successfully, but some node pages displays header, footer but it doesn't display the content which has bunch of nodes of node type FAQ. I have page--faq.tpl.php in template and node--faq.tpl.php. This is what I see when I go to /faq page:

I am not even able to see what is in my $variables array when I hook node via:

function joycone_preprocess_node(&$variables)
{
    kpr($variables);
}

I should at least see whats in $variables when I go to /faq page. But it doesnt even print kpr.

I wanna display FAQ nodes(node type is FAQ) where it says "The requested page '/faq' could not be found.". Here is my question:

Do I need to use some sort of template hook so drupal 7 theme get that dynamically? Because I have product and promotion pages that I wanna display product and promotion nodes at /products and /promotions page.

I am not sure if Drupal 7 gets what nodes will be displayed at what page automatically via template naming. If I need to use preprocess hook what will it be?

Or do I need to create individual modules for each page and pass nodes to template like that?

Any help would be appreciated. Thanks for your time.


texts: Webform: send uploaded files as attachments

texts:
I have a webform where a user can upload a file; I want this file to be attached to the email sent to the site manager.

What is the best practice doing so? I tried finding a helper module, but I didn't find one.


texts: Migrating a Drupal 7 domain to another domain while keeping dynamically generated URLs intact?

texts:
I currently have a website that does repairs and web development.

I want to separate the repair section of the website into its own domain name while also keeping the old domain's URLS intact. Since I have many pages generated by views I'm not sure how to go about doing this.

What I was thinking was clone the current site and remove what is unnecessary on the new site.. then the old site would redirect all those links to the new domain.

What is a good solution to such a migration problem?


texts: Taxonomy Term Block View Show Nodes For All Terms in Node?

texts:
Hello i achived this once but for some reason i am having a problem with it this time.

Using D6 and Views 3. I have a block view for random videos.

Taxonomy Term ID from URL
Load default argument from node page,
Validator: taxonomy term
Argument Type - Term id's by , or +

Iv checked and unchecked both-

Allow multiple terms per argument

and

Allow multiple arguments to work together

without much success. The desired output would be on a node tagged with 'science' and 'spirituality' the block view would show nodes that are either tagged 'science' or 'spirituality'. At the moment i seem to be getting no results or only nodes tagged with both 'science + spirituality'.

Does anyone know the correct settings for me to show nodes with any of the node's tags?

Thanks


texts:
I want to manage my footer menu, but I get this error:

The website encountered an unexpected error. Please try again later.

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "contact.site_page" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 190 of core/lib/Drupal/Core/Routing/RouteProvider.php).
Drupal\Core\Routing\UrlGenerator->getRoute('contact.site_page') (Line: 269)
Drupal\Core\Routing\UrlGenerator->generateFromRoute('contact.site_page', Array, Array, 1) (Line: 105)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('contact.site_page', Array, Array, 1) (Line: 753)
Drupal\Core\Url->toString(1) (Line: 167)
Drupal\Core\Utility\LinkGenerator->generate('Contact', Object) (Line: 94)
Drupal\Core\Render\Element\Link::preRenderLink(Array)
call_user_func(Array, Array) (Line: 376)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 183)
__TwigTemplate_c1bdd8f86c8cc62844cbb93f33c11d8a2e27610acf3c1abe4f7e3e1886bfcf45->doDisplay(Array, Array) (Line: 379)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 347)
Twig_Template->display(Array) (Line: 358)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/classy/templates/dataset/table.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('table', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Maybe it's caused by contact module, but I hav uninstalled it.


texts: Sorting options in an entity reference Select list within a form

texts:
When I change the input method for an entity reference field from an Autocomplete widget for a Select widget of an admin-side form, I have noticed there are no sorting options available under "Manage form display" and the Select widget is by default sorted by entity ID.

Is there a way to sort the entities in that Select widget by another field (in my case 'title')? I saw a note about this, but that pertains to drupal 7 (and my entity type is custom and not a node extension).


texts: How to disable panel cache for user menu?

texts:
I have a panel page and this page is front-page of my site. This page is not for anonymous users and having a user menu with welcome message like.
Welcome [Username], then other user related menus.

But sometime it shows wrong welcome user name. For example there is two users UserA and UserB.
First time UserA logins into site and it shows "Welcome UserA" after logout UserA other user UserB logs in to the site then welcome message is stills showing with UserA which is not correct.

This is may be due to Drupal cache because when I clear the all cache then it shows the Welcome message for UserB.

I have set the nocache from the panels pan setting for user menu.

How can I disable the cache for that page?

Thanks in advance.


texts: How to fetch list of published webforms from webform module?

texts:
How can I fetch list of published webforms from webform module?

I want to show all published webforms in dropdown to the user, so user can select one of the available forms.

Cheers
-Zafar


texts: How to retrieve datetime from database in Drupal?

texts:
How do I retrieve a DateTime column from my MySQL database using Drupal Database API + PHP. The DateTime format is in YYYY-MM-DD HH:MM:SS(2013-02-20 23:59:59). I want to retrieve all the rows in the database that match a specific date, and then store the hour inside an array.

For example, I want to grab all the data from January 1, 2013. I then only want to store hours 00:00 to 23:59 inside my array, not the entire date.

I do not want to use any modules to accomplish this.. because I need to code it inside my custom module.

Thanks for your help!

Current Code:

$query = db_select('Project', 'p');
$query->fields('p', array('submissions', 'date_time'));
$query->condition('p.user_id', $user->uid);
$results = $query->execute()->fetchAll();
foreach($results as $r) {
    $rows[] = array(strtotime(date("H:i:s", $r->date_time))*1000, $r->submissions);
}

I plan to display the data on my Flot line graph.


texts: Where can I edit the contents of global: custom text

texts:
I'm using Commerce Kickstart for a while now, but I can't seem to show discounted prices in product lists.
In my product displays, the discounted price is shown, as it's supposed to.

So I thought I just needed to change the field in the "Collection products" view. But this view uses a global: custom text field. I think I need to fix this in some tpl file, but I can't seem to find it anywhere.

So, any tips on where I can change the selected fields for "Collection products"?
Or any other tip on how to display discounted prices in the product lists an easier way?

(BTW, I'm using Commerce Price Savings Formatter module, not sure if this is relevant)


texts: Views module error after migrating to new server

texts:
After putting my website (in drupal 7) online today, I got a few strange errors from the 'View' module. On my local machine everything is working fine, but online I just keep getting those errors! I already checked the php version, php limit, hosting space, .. etc, everything is fine. I tried deleting all my views and adding new ones aswell, but this doesn't work either; when I try to save, nothing happens. These are the errors I'm talking about:

Notice: Undefined index: fields in views_db_object->init() (line 2175 of /home/kvclinke/public_html/sites/all/modules/contrib/views/includes/view.inc).
Warning: Invalid argument supplied for foreach() in views_db_object->init() (line 2175 of /home/kvclinke/public_html/sites/all/modules/contrib/views/includes/view.inc).
Notice: Undefined index: fields in views_db_object->init() (line 2175 of /home/kvclinke/public_html/sites/all/modules/contrib/views/includes/view.inc).
Warning: Invalid argument supplied for foreach() in views_db_object->init() (line 2175 of /home/kvclinke/public_html/sites/all/modules/contrib/views/includes/view.inc).
Notice: Undefined index: fields in views_db_object->init() (line 2175 of /home/kvclinke/public_html/sites/all/modules/contrib/views/includes/view.inc).
Warning: Invalid argument supplied for foreach() in views_db_object->init() (line 2175 of /home/kvclinke/public_html/sites/all/modules/contrib/views/includes/view.inc).

After checking my serverlogs, I also found this:

[Thu Oct 10 13:08:17 2013] [error] [client 213.224.29.86] ] [notice] EACCELERATOR(12762): PHP crashed on opline 3689348415265695042 of form_execute_handlers() at /home/kvclinke/public_html/includes/form.inc:1465, referer: http://www.kvclinkeroever.be/admin/structure/views/view/test

Anyone knows a fix for this or what the cause of this problem is? Thanks in advance!


texts: How to add a new calculated field by using `hook_views_query_alter`?

texts:
I have three node types that I have created relations between using the Relation module.
Seaon --> Player --> Week

The player node has a numeric field called cost.
The relationship between the player and the week has a numeric field called score.

The following is a views query (with some alias changes to make it a tad more intelligible) that I use to summarise data per season.
The view works fine but I need to add a calculated field that takes the sum of the weekly scores and divides it by the player cost.

SELECT  PLAYER.title AS PLAYER_title
        ,PLAYER.nid AS PLAYER_nid
        ,PLAYER_COST.field_cost_value AS PLAYER_COST_field_cost_value
        ,MIN(PLAYER.nid) AS PLAYER_nid_1
        ,'node' AS field_data_field_cost_node_entity_type
        ,MIN(PLAYER2WEEK.rid) AS PLAYER2WEEK_rid
        ,'relation' AS field_data_field_score_relation_entity_type
        ,SUM(PLAYER2WEEK__field_data_field_score.field_score_value) AS PLAYER2WEEK__field_data_field_score_field_score_value
FROM    {node} SEASON
INNER JOIN
        {field_data_endpoints} FDE
ON      node.nid = FDE.endpoints_entity_id
AND     (FDE.bundle = 'player_in_season'
AND     FDE.endpoints_entity_type = 'node'
AND     FDE.endpoints_r_index = '1')
INNER JOIN
        {field_data_endpoints} FDE2
ON      FDE.entity_id = FDE2.entity_id
AND     (FDE2.endpoints_entity_type = 'node'
AND     FDE2.endpoints_r_index !=  FDE.endpoints_r_index
AND     1 = '1')
INNER JOIN
        {node} PLAYER
ON      FDE2.endpoints_entity_id = PLAYER.nid
AND     FDE2.endpoints_entity_type = 'node'
LEFT JOIN
        {field_data_endpoints} PLAYER_FDE
ON      PLAYER.nid = PLAYER_FDE.endpoints_entity_id
AND     (PLAYER_FDE.bundle = 'has_weekly_score'
AND     PLAYER_FDE.endpoints_entity_type = 'node'
AND     PLAYER_FDE.endpoints_r_index = '0')
LEFT JOIN
        {relation} PLAYER2WEEK
ON      PLAYER_FDE.entity_id = PLAYER2WEEK.rid
LEFT JOIN
        {field_data_field_cost} PLAYER_COST
ON      PLAYER.nid = PLAYER_COST.entity_id
AND     (PLAYER_COST.entity_type = 'node'
AND     PLAYER_COST.deleted = '0')
LEFT JOIN
        {field_data_field_score} PLAYER2WEEK__field_data_field_score
ON      PLAYER2WEEK.rid = PLAYER2WEEK__field_data_field_score.entity_id
AND     (PLAYER2WEEK__field_data_field_score.entity_type = 'relation'
AND     PLAYER2WEEK__field_data_field_score.deleted = '0')
WHERE   (( (node.nid = '3' ) )
AND     (( (node.type IN  ('SEASON')) AND (node.status = '1') )))

From all the reasearch I've done, it looks like the correct option is to use hook_views_query_alter() to add the new field.
This is where I lose it, I have no idea how to write the code to build the new field.
Essentialy, based on the query above the field needs to be

SUM(PLAYER2WEEK__field_data_field_score.field_score_value) / PLAYER_COST.field_cost_value AS new_field

I just need some help in getting strated on the code in my custom module

This answer seems to meet my requirements conceptually, I am just lost on how to construct the function.


texts: How can I check the status code of a page?

texts:
I want to check the status code of a page. I have tried with the following code in hook_preprocess_page(), but it doesn't work.

$status = \Drupal::requestStack()->getCurrentRequest()->attributes->get('exception');

$status = \Drupal::request()->attributes->get('_route');
if ('system.404' === $route_name) {
  // Omissis.
}

How can I check the status code for a page?


texts: Issue with grouping in a view using Views PHP

texts:
I posted this a week ago at the drupal.org issue queue for Views PHP, but have not received a single response, so I'm hoping someone here can help me.

I have a view that displays a conference schedule. Each session is associated with a track (taxonomy), and gets a track icon to display. There's also one or more speakers per session (entity references to the speaker nodes). There's one type of session that needs to be associated with all the track types, but we don't want it to have a visual indicator. In order to get the icon to display conditionally, I used a Global PHP field. It prints the icon (if the conditions are correct) and then the session number and title, all on a single line. This works. The view is grouped first by date/time, so all sessions on Wednesday at 10 AM show up under a single heading. This also works. Here's the output code of the Global PHP field:

<?php
if(isset($data->field_field_hide_track[0]['raw']['value'])) {
    if($data->field_field_hide_track[0]['raw']['value'] == '0') {

    $image_vars = array(
        'path' => file_create_url($data->field_field_track_icon[0]["rendered"]["#item"]["uri"]),
        'alt' => $data->field_field_track_icon[0]["rendered"]["#item"]["alt"],
        'attributes' => array(
          'class' => array('session_list_track_logo')
        )
      );

    $track_logo = theme('image', $image_vars);
    print "
" . $track_logo . " " . $data->field_field_session_number[0]['raw']['value'] . " | " . $row->title . "
";
    }
    else {
      print "
" . $data->field_field_session_number[0]['raw']['value'] . " | " . $row->title . "
";
    }
}
?>

Before adding the Global PHP, it was secondarily grouped by a dummy field that had its output rewritten to concatenate session number and session title. (both individual fields were hidden from display.) This worked, but we couldn't display the icon conditionally.

That's where the Global PHP field comes in. If I group by date/time and then by the php field, it's inconsistent between session records. Sometimes it prints the php field twice, regardless of how many speakers there are. Sometimes it prints it once for each speaker. Sometimes it prints once for the first speaker, and a second time for the next chunk of speakers.

grouped by date/time and session number (both excluded from display); displaying php field

grouped by date/time and php field (both excluded from display

I've also tried grouping by all possible common fields (date/time, session number, session title, icon, and php field) which gives me such a mess I couldn't even get a decent screenshot of it because a single record doesn't fit on my screen!

This is the desired result:

I'm attaching screenshots of all of these, as well as a mockup shot of the desired result. Can anyone help me out? (Note that the groupBySessionNumber.png screenshot was taken after the Global PHP field was added, and the icon/number/title line is a result of that field.)


texts: Views: PHP conditional within loop (views-view-fields--)

texts:
Ok,

I've been working to have a simple php conditional set up in the tpl files for a view. But the automatic loop Drupal does to this file does has been driving me nuts.

My goal is to have a title field become a link only if someone in the CMS says it needs to be linked, say through another field (checkbox).

I'm currently working in the views-view-fields-- filed for my view.

My two fields: my_checkbox (bool) and my_title (string)

$var = $row->field_field_my_checkbox[0]['rendered']['#markup'];

foreach($fields as $id => $field):
    if ($var = 0):
        print $fields['field_my_title']->$content;
    elseif ($var = 1):
        print "<a href>" . $fields['field_my_title']->$content . "</a>";
    endif;
endforeach;

It is good idea to try what I'm doing in this location in the view tpl files? Should I be focusing in the views-view-field-- tpl instead? Which I'm unsure how you could pull another fields output here.

I'd like to stick to coding this and not do this in the CMS for easy re-usability. Thanks in advance.


texts: How to render a views title in .tpl file?

texts:
I embed a view in a .tpl file but it doesn't show the title. It only shows the content.

How to render the title of the view?

I'm using the code below:

<?php
print views_embed_view('dummy');
?>


texts: How to set up Drupal behind a proxy correctly?

texts:
I have a Drupal 7 website on the domain hiddendomain.be:3200. Users visiting publicdomain.be are proxied to the hidden domain. My home page is rendered just fine, but when I log in with the existing account TestUser, I get a "You don't have access rights to this page" message. It seems that Drupal still handles the user as anonymous, because going to publicdomain.be/user immediately afterwards returns the login form again. However, in the log report, a new session has been created for TestUser. Why does this happen?

I have been browsing the web for answers, but the only thing I found was to edit the settings.php file in the default directory (in my case that is settings.local.php) by adding

$conf['reverse_proxy'] = TRUE;
$conf['reverse_proxy_addresses'] = array('IP');

where IP is the IP address of the publicdomain.be server. Unfortunately, this does not work. What am I doing wrong?


texts:
I wrote my custom rest endpoint. I need to 2 URI both called with GET

/api/item/{id} to get single item identified by ID
/api/item to get the list of items.

i try with

  @RestResource(
    id = "my_id",
    label = @Translation("My label"),
    uri_paths = {
      "canonical" = "/api/item",
      "https://www.drupal.org/link-relations/index" = "/api/item/{id}",
    }

into my class i have

class ApiRestResource extends ResourceBase {

    public function get($id = NULL) {

but only canonical URI is found. the message for the second URI is

"message": "No route found for \"GET /api/item/1\""

how can i have 2 GET in my class?
thanks in advance


texts: How to use tokens in php code of the rules module?

texts:
I'm using Ajax_comments to add comments on nodes without having to reload the page on save. Now the "node history" doesn't get updated which throws off the "new comment" count.

I tried to create a rule to update the node history on "comment save". Seems like my only option is to execute PHP code. How do I combine PHP code with tokens to get something like this:

if ([current-user:uid]) {
   db_merge('history')
     ->key(array(
       'uid' => [current-user:uid],
       'nid' => [comment:node:nid],
     ))
     ->fields(array('timestamp' => [site:current-date]))
     ->execute();
  }


texts: Making sure edits work as intended before publishing

texts:
I just wanted to pre-empt a situation that is highly likely to occur at some point in the future. I am going to be hosting a small online business using shared hosting. Obviously, once the website (which uses Drupal) is finalized and I take it out of maintenance mode, I want to keep it usable 99.99%. However at some point of time, I'll  probably wish to make some edit, add content or even make some reforms that will need some thorough testing. I know that there is a preview button but for some alterations this may not be enough, but I'd still like to avoid putting the site in maintenance. (Although for fixing bugs and critical updates I obviously would).

I'd appreciate your suggestions on how I could do this please. I assume it must be a common issue among online businesses?


texts: Delay in code changes on custom pages in drupal 8 in a docker environment

texts:
There is a delay between saving code changes in a controller and being able to view them in the browser.

This is frustrating (to say the least) and makes it very hard to develop and debug module code.

I have tried setting up a development environment in docker and it's working quite well except for this nasty and unpredictable delay.

For a minimal example I tried installing the Hello World example module from the Prepare a Module skeleton guide.

My (minimal, but complete) setup is available here: https://github.com/glaux/drupal8docker.

To replicate the delay

Get the site up and running.
Log in as admin with pass 123 on http://localhost:8090
Navigate to /hello
Change the markup in the file /docker/project/modules/D8HWexample/src/Controller/HelloController.php
Refresh /hello - the changes will show up after between 5 and 300 seconds.

What I've tried

I've tried disabling all the caches by following the official guides. When making css changes to a custom theme (not included in the minimal repo above) the code changes are visible immediately, so this is not a cache problem I believe.

This is also emphasized by the fact that rebuilding the cache via the interface, drush and/or drupal console seems to have no effect on this delay.

In a similar manner I've tried disabling the browser cache (by opening the dev console on chrome). This have no effect either, nor have clearing the browser cache manually.

How can I get rid of this delay, what am I doing wrong here?

Edit

I think Clive could be right that this is possibly on the file system level. Here is an excerpt from the docker-compose file:

volumes:
  - ./docker/project/modules:/var/www/html/modules
  - ./docker/project/themes:/var/www/html/themes
  - ./docker/project/libraries:/var/www/html/libraries
  - ./docker/project/profiles:/var/www/html/profiles
  - ./docker/project/sites:/var/www/html/sites
  # Add anonymous volumes to exclude cache files explicitly
  - /var/www/html/sites/default/files/js
  - /var/www/html/sites/default/files/css
  - /var/www/html/sites/default/files/php

The files are added as explicit volumes, and the changes I make to HelloController.php are reflected in the image. I'm running this on Windows 10. Could this be the culprit, and how can I test this?


texts: What is difference between field tables?

texts: What is the difference between a content_field_myfield and field_data_field_myfield in the db?


texts:
How do you restrict a .html file/page with drupal so that only logged in users can access it?

Basically I have this .html file I need to put up, I don't care whether or not it's a content-page or just simply a file - but I need only those who are logged in to be able to access it.

I've tried simply pasting the html-code in content-creator (read; /?q=node/add/page), but that crashed my site and I had to manually remove the node from the database to get it working again - so that's not an option.


texts: Error "The value you selected is not a valid choice" in Avatar Kit field settings

texts: I just tried Avatar Kit 8.x-1.0-beta2. I created a few Gravatar generator presets but after adding the Avatar Generator field to the user entity and trying to select one of the Avatar Generator radio options I get the error "The value you selected is not a valid choice" on clicking "Save settings". The same error occurs when trying to edit a user. Here's what I'm seeing:


texts: How do I implement a custom theme function?

texts:
I'm trying to print a markup in a peg. I've implemented a function passed the values through the variables. Also I've implemented a custom theme function with a markup.

But it is giving the error.

  Template "modules/custom/example/templates/example.html.twig" is not defined (Drupal\Core\Template\Loader\ThemeRegistryLoader: Unable to find template "modules/custom/example/templates/example.html.twig" in the Drupal theme registry.).

Here is my code.

/**
 * Implements hook_theme().
 */
function example_theme($existing, $type, $theme, $path) {
   return array(
    'example' => array(
      'variables' => array('items' => array()),
    ),
  );
}
// Theme function
function theme_example($variables) {
   return 'hi'
}
// Preprocess implementation.
function template_preprocess_example(&$variables) {
  $value = 'hi how are you';
  return $value;
}

I've implemented both one after another, but they didn't work. Is the custom theme function format changed in Drupal 8?


texts: How to list only the latest revision of all nodes in a view?

texts:
I currently have a view that lists all of our nodes which is what we use for a content dashboard. It shows the most recently updated nodes, their workflow status, and a few other details.

The problem we seem to be having is that we're using Revisioning which creates a new pending revision each time a user updates a node. When a user updates a node, the workflow state (custom CCK field) switches to Review automatically. Since the current published node has the workflow state Live, the view's workflow field does show "Review". I'm assuming this is because the view is only pulling the currently published content and not the pending revisions content.

When using the view type Node Revisions it lists every revision of a node, not just the latest one. This is a problem because our dashboard would be filled with a single node's revision history instead of all the current nodes.

Is it possible to create a view that lists only the latest revision (pending, or current) of all nodes on our site?

Version info
Drupal 6.22
Views 6.x-2.12


texts: Calling a Method from another Module's Class

texts:
I'm dumb and this is embarrassing, but I'm trying to figure out how I properly use a method from a class in other parts of my code. I need to understand the Drupal way, if not just the php way.
I have a class like this...
namespace Drupal\module_name\Utilities;

use GuzzleHttp\Exception\RequestException;
use Drupal\Core\Logger\LoggerChannelFactory;
use Drupal\Core\Messenger\MessengerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use GuzzleHttp\ClientInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;

class Example implements ContainerInjectionInterface {

  private $client;
  protected $loggerFactory;
  protected $messenger;
  protected $config;

  public function __construct(
    LoggerChannelFactory $loggerFactory,
    MessengerInterface $messenger,
    ClientInterface $client,
    ConfigFactoryInterface $config
  ) {
    $this->loggerFactory = $loggerFactory->get('simple_mailchimp');
    $this->messenger = $messenger;
    $this->client = $client;
    $this->config = $config->get('module_name.settings');
  }

  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('logger.factory'),
      $container->get('messenger'),
      $container->get('http_client'),
      $container->get('config.factory')
    );
  }

  public function request() {
    return 'whatever';
  }
}

What's the proper way to use this class somewhere else? For instance, in another module, I want to call the request() method shown above.
  $example = new Example();
  $x = $example->request();

This doesn't work, as shown above. I get this...
ArgumentCountError: Too few arguments to function Drupal\module_name\Utilities\Example::__construct(), 0 passed... and exactly 4 expected

(Even though it seemed to have worked at one time.)
That said, what's the right way to go about this with Drupal, or in general, I guess?


texts: Showing fields from different bundles that are related

texts:
I'm trying to display the fields of one content type while searching on another content type. More specifically... here is my situation:

I have a view based on an index with fields in Organism and fields in mRNA.

Content type: Organism
Fields: order, common name, genus, species

Content type: mRNA
Fields: description, scientific name (Genus species)

I set up search filters for description, order, common name, scientific name. The result should look something like:
link to mRNA page
order | scientific name | common name
description

However, if I actually search by description, nothing shows up for order and common name. I feel like this is the result of an outer join of the two content types.

How would I "inner join" organism on scientific name? I've tried looking into EntityReference module but it seems like I would have to manually fill in the entity reference for every mRNA page I have... which isn't what I want.

Thanks


texts: Appending markup to privatemsg message body

texts:
First, a little background info:

I'm running privatemsg 7.x-1.2 across several sites running on a single D7 codebase. I have all of the privatemsg tables in one database, which is accessed by all of the sites as to keep private messages synchronised between them.

To enhance that little setup, what I would like to do is manipulate the message body at the time of insertion/saving to append a "This message was sent via [site name]" line at the very end of each message. This is how I achieved it at first:

function global_privatemsg_message_presave_alter(&$message) {
    $message->body .= "
(". t("Sent via !site_link", array('!site_link' => get_site_link())) .")
";
}

That worked well except I overlooked the fact that hook_privatemsg_presave_alter takes place prior to the input filter being applied, so if the user sends their message as "Filtered HTML" or "Plain text", the 'sent-via'  gets thrown out.

So, what I'm looking for is a reliable way of appending markup to the message body, or even introducing a new template variable that I can populate accordingly, without it being mangled by input filters (the result of Drupal's check_markup, I suppose).

Preferably I want to do this entirely within the constraints of the Privatemsg module API, but I appreciate that might be asking for the impossible.

Doable?


texts: hook_page_attachments() not called from mytheme.theme file

texts:
I am trying to load an asset library in my Drupal 8 custom theme. I have created the library and can load it via mytheme.info.yml file.  However, if I try the load it using hook_page_attachments() in the mytheme.theme file, then the function is not called.

I did a search for this function in the Drupal 8 standard installation and it only ever seems to be called from modules.  Can hook_page_attachments only be called from modules? Any suggestions on why this is not working.

mytheme.theme file content:

function mytheme_page_attachments(array &$attachments) {
  $attachments ['#attached']['library'][] = 'mytheme/general-js';
}


texts:
In mymodule.install i try to implement a hook_uninstall call, but it never triggers. What am I doing wrong?

function hook_uninstall() {
echo "uninstalling";
...more stuff...
}


texts: What's wrong with my GET request? (Commerce Services, REST)

texts:
I'm developing a mobile app to connect with my Drupal Commerce (Kickstart) store, using a REST server.

When I do GET: endpoint/rest/product it retrieves the products list

<result is_array="true">
    <item>
        <revision_id>1</revision_id>
        <sku>TOT1-GRN-OS</sku>
        <title>Tote Bag 1</title>
        <revision_uid>1</revision_uid>
        <status>1</status>
        <log />
        <revision_timestamp>1423972403</revision_timestamp>
        <data />
        <product_id>1</product_id>
        <type>bags_cases</type>
        <language>und</language>
        <uid>1</uid>
        <created>1423972403</created>
        <changed>1423972403</changed>
        <title_field>Tote Bag 1</title_field>
        <commerce_price>
            <amount>1600</amount>
            <currency_code>EUR</currency_code>
            <data>                <components />
                </data>
        </commerce_price>
        ...
    </item>
    <item>
     ...
    </item>

Everything looks fine. I can even GET endpoint/rest/product?status=1 and it does filter well.

I'm trying to filter by commerce_price.amount:

GET endpoint/rest/product?commerce_price.amount=1600

but it's not working. I have no problems filtering by a first level key, but can't access second level ones and so on. What am I doing wrong?


texts: prompt in IE8 for secure pages produces altered layout

texts:
My Drupal 7 website looks fine in most browsers, but in IE8 I am getting the prompt:

    "Do you want to view only the webpage content that was delivered securely? This webpage contains content that will not be delivered using a secure HTTPS connection, which could compromise the security of the entire webpage."

Then a "Yes" or "No"

If the person selects "yes" they are presented with MOST of the page, but odd things like the sidebar CSS and body content don't display properly. Is this an issue with securepages module or something else? Initially I had secure pages turned off because I moved from a dev server (without SSL) to production. But even after turning it on, I get this message. I have:

Cleared the cache
Run the security review module (passes on all
points)
Ensured the core and all modules are up to date.

Also, I have the following lines in my settings.php file:

$base_url = 'https://my-website-here.org';

and

$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//';
$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe? g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i';
$conf['404_fast_html'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa-1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><title>404 Not Found</title>
Not Found

The requested URL "@path" was not found on this server.
';

Also, could jquery menu or Client-side adaptive image be causing a problem? The context module? These were all additions from the previous site that ran fine.

Any help appreciated!


texts: D7 Organic groups and securing private files

texts: I'm looking for a current solution for private file protection in D7 (so files uploaded without a node can be hidden from unauthorized users). I saw this question, organic groups and private files, but it's solution is pointing to a project for D6. Is there a D7 solution out there?


texts: Proper approach for showing menu based on node

texts:
I'm setting up a new Drupal site and created a content type, taxonomy, and two menus. The taxonomy just has 2 items, which correspond to the menus. What I'd like to do is render the corresponding menu in a sidebar when the user is viewing a node from the content type, ideally highlighting the current item in the menu.

My current thinking is to write a custom module and use the hook_page_build. Then in that hook, see if arg(0) is 'node' and arg(1) is numeric and then node_load arg(1) and then if that node's type matches my content type, then field_get_items to get the node's taxonomy and pull the corresponding menu and then add it to $page['sidebar_first'].

Is this the right approach or is there a better way?

Thanks in advance!


texts: How to have exposed filters not displayed on search results

texts:
This is hard to explain so I'm attaching an image.

When someone clicks on a filter to search for something, I would like the resulting page to show results but not the filter. Maybe simply a link like "back to search".

Or possibly a small search box, like basic search but not every filter.


texts: I can't see the newly added toolbar buttons I added to CKEditor

texts:
I have added some new buttons from the toolbar configuration onto the BasicHTML profile of CKEditor
(admin/config/content/formats/manage/basic_html)
I've added the standard text alignment buttons and also the color button which was supplied by the module I installed (details below)

However, when I try and use the editor (whether in paragraphs, or the standard wysiwyg supplied by Drupal), the new buttons don't appear. I've cleared caches etc.

Does anyone know what I'm missing ?

I am using:

Drupal 8
CKEditor 8.85
CKEditor ColorButton 8.x-1.2

I've installed the color button module and uploaded the 2 libraries (colorbutton & panelbutton)


texts: How can I hide a block on specific content types in Drupal 8? There's the setting for displaying blocks only on specified content types, but not for hiding them. Looks like the PHP filter is out in D8, so not sure how to go about this. I'm sure it's a simple fix.


texts:
I'm trying to create a custom REST GET resource for a specific node type, and I have the class created and enabled via the REST UI module settings (using the current 1.x-dev release so configs are generated w/o me having to manually create a routing.yml file). For reference, here's the class code:

<?php
/**
 * @file
 * Custom Rest resource for video nodes.
 */

namespace Drupal\video_export\Plugin\rest\resource;

use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;
use Drupal\Core\Session\AccountProxyInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Psr\Log\LoggerInterface;

/**
 * Provides a resource for database watchdog log entries.
 *
 * @RestResource(
 *   id = "video_export_source",
 *   label = @Translation("Video Export Source"),
 *   uri_paths = {
 *     "canonical" = "/videos/feed/{site}"
 *   }
 * )
 */

class VideoExportResource extends ResourceBase {
  /**
   *  A curent user instance.
   *
   * @var \Drupal\Core\Session\AccountProxyInterface
   */
  protected $currentUser;

  /**
    * @param array $configuration
    *   A configuration array containing information about the plugin instance.
    * @param string $plugin_id
    *   The plugin_id for the plugin instance.
    * @param mixed $plugin_definition
    *   The plugin implementation definition.
    * @param array $serializer_formats
    *   The available serialization formats.
    * @param \Psr\Log\LoggerInterface $logger
    *   A logger instance.
    * @param \Drupal\Core\Session\AccountProxyInterface $current_user
    *   A current user instance.
  */
  public function __construct(
    array $configuration,
    $plugin_id,
    $plugin_definition,
    array $serializer_formats,
    LoggerInterface $logger,
    AccountProxyInterface $current_user) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $serializer_formats, $logger);

    $this->currentUser = $current_user;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->getParameter('serializer.formats'),
      $container->get('logger.factory')->get('rest'),
      $container->get('current_user')
    );
  }

  /**
    * Responds to GET requests.
    *
    * Returns a list of video nodes to be imported into the target site.
    *
    * @return \Drupal\rest\ResourceResponse
    *   The response containing a list of bundle names.
    *
    * @throws \Symfony\Component\HttpKernel\Exception\HttpException
 */
  public function get($site = NULL) {
    $response = ['message' => 'Hello, this is a rest service'];
    return new ResourceResponse($response);
  }
}

However, when I access my URL via http://mysite/videos/feed/sourcesite?_format=xml, all I get is this error:

  No route found for "GET /videos/feed/newsbusters"

and my debugger doesn't even hit my get() function. In reading the RESTful Web Services API overview docs it appears that I might be missing the second part of the uri_paths setting in the class annotation. However, the example doesn't make sense to me for my use. if the canonical url is just /videos/export/{site} (where {site} is a parameter), what is the correct second part? Just http://myite.com/videos/export?

Or,

Thanks.


texts: How to get the URL for the re sized image

texts:
I have built a custom form in Drupal 7. The form has a file type field which allows the user to upload an image. I'm using the below code in the submit function to save and re size the image:

function adddeals_submit($form, &$form_state){
    global $user;

    $file = $form_state['storage']['file'];
    // We are done with the file, remove it from storage.
    unset($form_state['storage']['file']);
    // Make the storage of the file permanent
    $file->status = FILE_STATUS_PERMANENT;
    // Save file status.
    file_save($file);
    //get the url for the saved file
    $url = file_create_url($file->uri);
    echo $url;
    echo '<br>';

    $destination = 'public://ImageThumbnail';
    $img = image_load($file->uri);
    image_resize($img, 200, 200);
    $result = image_save($img,$destination);
    echo $result;

    exit;
  }

The image is re-sizing and saving correctly as the $result is printing 1. I need to know how to get the URL for the re sized image. Am I missing something?

Thanks for you help.


texts: Using 'Grouped Exposed Filters' for combinations of Taxonomy terms

texts:
I have a taxonomy of 'Investment Vehicles' containing 3 terms.

When a user adds a piece of content, they can select 1 or up to all 3 investment vehicles terms to classify their content.

I am then applying an 'Exposed Group Filter' as a radio input so that the user can filter between content with different combinations of 'Investment Vehicles.'

In the screenshot below you can see that the default 'any' option returns my 2 pieces of content but any change does not return any content at all and I am receiving the following error:


texts: How to show different content for various roles for the same url?

texts:
we have a use case whereby 6-7 types of user roles can access the same nodes (lots of them) and see different content based on roles.

For example a user with role A accesses sitename.com/faq and sees a particular content.
However when a user with role B accesses sitename/faq that they see some different content as based on their role. (Please note that we are not merely talking about translation here)

How would I get about getting this setup? I know that if we had 2-3 nodes that required such access that I could check it programmatically however in this case it is a lot of nodes and doing that would be problematic.

Any tips or modules that you can think off that would help me with that?

Many thanks


texts:
I'm looking for a way to make Feed items inherit a field value from its parent Feed importer node during the import. The idea is to later use this field value in views filter. In my case this field contains the nid value of referenced node that should be the same for Feed importer node and all of its feed items, and different for other importers and their feed items.

What I have found a quiet similar issue:
http://www.zivtech.com/blog/feed-feeds-importing-referenced-rss-data

but unfortunately I'm not very good at coding and cant find out the reason why this solution doesnt work in my case. Maybe there is a way to do this through views relationships or any other module like Rules or Node Hierarchy?

I also found an module for Drupal 6 that might do this kind of stuff but it wont work for Drupal 7 and Feeds module: FeedAPI Field Inherit

If some one has an advice for this issue please help. Thanks!


texts: How can i hard-wire a link, in blocks, using $base_url or something similar?

texts:
I'm trying, unsuccessfully so far, to create a block that is simple hard-wired link. but i need to use $base_url or something equivalent (like base_url(); ?) but i guess adding php is not allowed.

i tried a few different things in the block body. for example…

<a href="<?php print $base_url . '/archive/program-archive-2012--2013' ?>"> Archives

how i can achieve this, without using a full, or literal URL?


texts: Views content pane configuration problems after upgrade to organic groups 7.x-2.3

texts:
Ever since I upgraded from OG 7.x-1.5 to 7.x-2.3, the views content pane for my groups has been completely screwed up. I've been researching this for weeks with zero success. In the previous version of OG, I'd set up a content pane to deliver posts written by group members to the appropriate group pages. Now, however, all of the posts from all of the groups are showing up in every group.

I've tried all different kinds of contextual filter and relationship combinations within Views, but the ones that seem the most consistent across the different forum posts I've seen (and using OG Extras as a rough guide) are these:

Contextual filter: "(OG membership from node) OG membership: Group ID" (with these configurations: Relationship: OG membership from node/Provide default value: Type: Current OG group from context/Group Type: Node)/Specify Validation Criteria: OG Group)

Relationship: OG membership: OG membership from Node

In the "Pane Settings" area, under "Argument Input" I have "From Context" and the Required Context is "OG Membership ID"

Under "Filter Criteria" I have "Content Published (Yes)" and "(OG membership from node) OG membership: Group_type (= Node)"

This gives me two results which are not wanted:

1) A bulleted list of the group numbers with the number of posts in parentheses beside them and
 2) This bulleted list is on the landing page of every single group

Instead, I want the posts written by members of each particular group to show up on the landing page for that group.

In the node I'm overriding to display my content pane, I'm having trouble figuring out the "Context" and "Relationships" settings (I'm using Panels 7.x-3.3, in case that matters). The only OG-related relationship in 7.x-2.x is "OG membership from a group node and user", but when I try to add that as a relationship, I get the following error:

  Notice: Undefined offset: 1 in
  og_membership_from_group_and_user_context() (line 28 of
  .../modules/og/plugins/relationships/og_membership_from_group_and_user.inc

And I have no idea what context to add here. In short, I'm really confused. Can someone please give me a clue as to what I'm doing wrong?


texts: jsmin+ causes high server load in drupal 6

texts:
I have the JavaScript aggregator module on my site. Whenever I check the jsmin+ checkbox (so it uses jsmin+ instead on jsmin), the server becomes really slow. I have to use jsmin+, instead of jsmin, because jsmin doesn't group JavaScript files correctly, and I get JavaScript errors (Ckeditor and Vertical Tab are breaking).

Drupal 6.20
JavaScript aggregator 1.6
jsmin+ 1.4


texts: How to minimize conflicts in hook_update_N implementations with multiple developers?

texts:
I work on a team with multiple developers and we use hook_update_N functions in a "miscellaneous" module to make updates such as module or theme enabling/disabling, performing miscellaneous database updates, one-off variable assignments, and more. We often encounter conflicts when having code reviews, since multiple feature branch pull requests get approved around the same time, many with hook_update_N implementations that use the same number (N). The process of resolving the conflicts is slow because each conflict has to be resolved in series.

One option would be to have each developer create their own "glue" module and put their hook_update_N implementations in that module's .install file, but it seems wasteful to run multiple modules as a workaround for this problem.

Anyone have a good solution to avoiding or minimizing the conflicts?


texts: How to unset field in views conditionally

texts:
I'm using hook_views_pre_render() in a module to make sure an image field 'field_field_company_logo' is removed for a certain content type 'job_listing'. I have the following code, which works, but produces warnings:

function hideviewsfields_views_pre_render(&$view) {
  if ( ($view->name == 'job_search') && ($view->current_display == 'job_search_results') ) {
    $result = $view->result;
    foreach ($result as $row) {
      $type = $row->_field_data['nid']['entity']->type;
      if ( $type == 'job_listing' ) {
        unset ( $row->field_field_company_logo );
      }
    }
  }
}

It works, in as much as the correct images are omitted, but I get the following warnings:

Notice: Undefined property: stdClass::$field_field_company_logo in views_handler_field_field->get_items() (line 715 of /public_html/sites/all/modules/views/modules/field/views_handler_field_field.inc).
Warning: Invalid argument supplied for foreach() in views_handler_field->advanced_render() (line 1053 of /public_html/sites/all/modules/views/handlers/views_handler_field.inc).
Notice: Undefined property: stdClass::$field_field_company_logo in views_handler_field_field->get_items() (line 715 of /public_html/sites/all/modules/views/modules/field/views_handler_field_field.inc).
Warning: Invalid argument supplied for foreach() in views_handler_field->advanced_render() (line 1053 of /public_html/sites/all/modules/views/handlers/views_handler_field.inc).

I've seen elsewhere people writing code similar to the following:

unset($view->field[$field_name]);
unset($view->display_handler->handlers['field'][$field_name]);

where the first line seems similar to the unset I am executing, but I believe it was acting upon a different variable (i.e. not $views -- maybe $data?) and I can't find any other reference to the image field within the $view object that can be unset without it removing it altogether from the display.


texts: Display Exposed Filter value of selected exposed filter WITH CLOSE BUTTON

texts:
I work on drupal 7, and create a page from views used 2 exposed filter. I want to display exposed selected values and also close button in exposed selected values. I found this solution for one hand:

Instead override views tpl file to include the code as needed. Consider view page named "Exposed Filter data". "Display output" file can be found under "advanced"->"Theme: information" setting of view. Select last name from "Display Output" as the tpl file name. For this example file name is "views-view--exposed-filter-data--page.tpl.php". Clicking on "Display Output", you will get current code of the file. Include following code after $exposed is printed & its condition ends. Here is the code that needs to be done for displaying exposed selected values of all four dropdowns. Considering Lamp, Color Temperature, Luminous Flex & Wattage as Taxonomy Term Reference fields, current view is loaded & current selected values are displayed with a cross anchor link.

Note that here "data-field" value on anchor field are same as id of the select list.

<?php
  $year = '';
  $category = '';
  $view = views_get_current_view();
  if (isset ($view->exposed_input['field_year_tid'])) {
    $tid = $view->exposed_input['field_year_tid'];
    if (is_numeric($tid)) {
      $term_obj = taxonomy_term_load($tid);
      $year = 'X' . $term_obj->name;
    }
  }
  if (isset ($view->exposed_input['field_category_tid'])) {
    $tid = $view->exposed_input['field_category_tid'];
    if (is_numeric($tid)) {
      $term_obj = taxonomy_term_load($tid);
      $category = 'X' . $term_obj->name;
    }
  }
  echo $year . '  ' . $category;
?>

And then I am using JQuery for reseting the value of dropdown & submitting the form, when cross link is clicked. It does not work.

jQuery(document).ready(function(){
  jQuery('a.reset').live( 'click', function() {
    var datafield = jQuery(this).attr('data-field');
    jQuery('#'+datafield).val('All');
    jQuery( 'VIEW_EXPOSED_FORM_ID' ).submit();
  });
});

I am not sure where I supose to put this script. Does it have to be inside PHP function? I am using the form_id (views-exposed-form-exposed-filter-data-page) that I found in the code, but am I doing something wrong? Where I should put the script? Here is the website http://zliks.cat/cabrianes/exposed-filter-data


texts: Update webform field value using AJAX realtime

texts:
I have a webform created using the admin panel and would like to change one of its textfield values on click of a button. I have attempted doing this from hook_form_alter. I have given the wrapper name 'changeText' for this textfield from admin panel.

function fence_quote_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'webform_client_form_1'){
        $form['buttons']['fence_quote']  = array(
          '#type' => 'button',
          '#value' => t('Get online estimates'),
          '#ajax' => array(
              'callback' => 'fence_quote_form_callback',
              'wrapper' => 'changeText',
          ),
        );
       $form['field_meters']['#prefix'] = '
';
       $form['field_meters']['#sufix'] = '
';
    }
}

function fence_quote_form_callback($form, &$form_state) {
   $form_state['values']['field_meters']['und'][0]['value'] = '111';
   return $form['wrapper'];
}

The problem is I can't update 'meters' value using AJAX callback as it is a field created from admin panel and not from hook_form_alter. However if I place

$form['submitted']['meters']['#default_value'] = '111';

outside of the callback it works on page refresh. How can I do this?

As requested by @kamal-oberoi I'm uploading a screenshot of my full code.


texts: How do i customize theme_link() for a particular node, or view only?

texts:
i have a View that displays some DVD product teasers. What id like to do is customize or change the wording of the 'Read More' link of each teaser.

i also have another view where i want to remove that link altogether. now i know how to do this with CSS but i'm trying to learn how to override theme functions.

i have Themer Info turned on see a candidate function name for theme_link() but i think that would override all the theme_link functions for the entire site. how do i customize theme_link() for a particular node?

and how do i find out what function calls theme_link() ?, if i want to remove it entirely?

in other words, i need to get into $content variable!, how do i do that?

much thanks in advance!


texts: How to get  the last updated time stamp of a field in field collection.Is there any drupal built in function to get the timestamp


texts: Is it possible to do calculations like percentage in Views

texts:
I am using Views module.
The view has three columns.

In the third column, I want a calculated percentage using the first two columns of the view.


texts: How to save custom value in DB from custom .module

texts:
I have inherited a custom module, which groups together some field of an custom ContentType and sends it by email.

In the module there are 3 functions.

Email check preg match:

function __autoload($class_name) {
  require_once($class_name . '.lib.php');
}
require_once('vumclass.lib.php');

This function gets triggered when the node is saved or updated. Right?

function vumveranstaltungsmailer_action_info() {
  return array(
    'vumveranstaltungsmailer_action' => array(
      'type' => 'node',
      'label' => 'vumveranstaltungsmailer_action',
      'configurable' => FALSE,
      'triggers' => array('node_insert', 'node_update'),
    ),
  );
}

Do stuff, send email:

function vumveranstaltungsmailer_action($object, $context) {
//do Stuff, sends email. Not shown here.

//I want to set this field to empty/clear it
$object->field_email_mailer_01['und']['0']['value']->set(NULL);

}

Bare with me, I am pretty a beginner/noob. I am a bit overwhelmed where and how to do it. Please give me a simple solution, so I understand it. Quick and dirty is fine for me ;-)


texts:
I try to customize fieldset ABC that are inside drupal commerce checkout page.
Markup looks like this

<fieldset>
 <legend>ABC</legend>

</fieldset>

I would like to put some additional code directly inside fieldset and then also some other html directly inside form-item elements.
Question> What should I do to achieve that? I found this page https://api.drupal.org/api/drupal/includes!form.inc/function/theme_fieldset/7 would it be of any help? Thank you.

images


texts:
I have a really simple form with a file upload. It actually used to work until I recently noticed it's not saving the file. When I check for the submitted values, the file field is empty, but the file is in $_FILES.

Here is how I build the form:

function tag_graphics_form($form_state) {
    $form = array();
    $form['tag'] = array(
        '#required' => TRUE,
        '#type' => 'textfield',
        '#title' => t('Tag'),
        '#size' => 30,
      );
    $form['image'] = array(
        '#type' => 'file',
        '#title' => t('Image for tag page'),
        '#description' => 'Recommended width for image: 605px'
    );
    $form['description'] = array(
        '#type' => 'textarea',
        '#title' => t('Page Description for SEO')
    );
    $form['#attributes'] = array('enctype' => "multipart/form-data");
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Save'
    );
    return $form;
}

And this is how I process things in the submit:

function tag_graphics_form_submit( $form, &$form_state ) {
    // save the image and put to the database
    print_r($form_state['values']);  // the image field is completely empty here. other fields are ok
    print_r($_FILES); // the uploaded file is here just fine
    if ($form_state['values']['image']) { // all of this used to work...
        $validators = array();
        $file = file_save_upload('image', $validators, file_directory_path());
        file_set_status($file, FILE_STATUS_PERMANENT);
        $filepath = $file->filepath;
    }
    // more code...
}


texts: How to edit live theme .info file (localhost)

texts:
I'm currently building a custom theme from the ground up on drupal on localhost.

At the moment I've managed to add my theme and run my custom templates succesfully. However I can't get it to pick up my CSS or JS files.

These were the lines in my .info file

stylesheets[all][] = /css/main.css
scripts[] = javascript/javascript.js

However I got an error in the console saying:

'GET http://localhost/drupal/css/main.css 404 (Not Found)'

So I modified the path of the css and js files to something like this:

stylesheets[all][] = sites/all/themes/THEMENAME/css/main.css

Yet it still can't find it. I'm not sure what's going on. Has the .info file been cached?


texts: How to include "File upload" field in the webform composite element?

texts: I have created a custom composite element, I want to include "File upload" field...The field is visible to the user and the file is uploaded. But it is nowhere saved.


texts: Latest Saved Content keeps appearing on the front-page despite being configured in "content" and "content type"

texts: Latest saved content without the title, always appears on the front page even thought in "Content" and "Content Type" it is configured not to show up on the front-page.  The content is also disabled in the blocks, but it still appears on the front page.


texts: Show entity reference content with a field other than the title

texts:
I want to add a field to a custom content type that allows users to select other content from the site to display as a list on the given node.

I can do this by creating an entity reference field to content type. This works, but I can only seem to have it show the link in reference to the Title field of the corresponding node. I want to set a different field as the link. How do I do this?

If I could show the fields in a view, I could select the field to show more easily, however, I have not found a way to have a view show the contents of a field from the current page.

Originally, I had implemented this via a system of taxonomy terms and a view but my users want the ability to go in and manually set the relationships so I have had to fall back to this. If someone has a better suggestion for this problem I would love to hear it.


texts: Creating specific front pages for departments

texts:
The Drupal 7 site I am working on has its own company front page, and there are a couple of branches of the company in different location. I want to add specific front pages with "about / contact us / other menus" for each of those departments/branches of the company that will be displayed when each of the branches is accessed.

How can I achieve this?


texts: 7 Unable to use file_usage_add when adding new content (node id doesn't yet exist)

texts:
I have a custom widget with custom field definitions. I am using hook_widget_form to create my fields, and I am attached a custom validation function using the #element_validate property on a fieldset wrapper to my custom fields. Everything is working as intended, especially when updating existing nodes; however, when creating new nodes I am running into a two-pronged problem when it comes to having images in my custom fields.

I am using file_usage_add to bind images to the node, but this creates a problem when adding a new node as the nid does not yet appear available in the validation stage of saving (as expected). In these instances, I've used a condition to skip the file_usage_add call, but that leads me to a new error (The file used in Masthead Image field may not be referenced). Below is a simplified version of what I'm attempting:

function hook_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
    // Setting switch into parameters that wll work widget types that are in module.
    $widget = $element;
    $widget['#delta'] = $delta;
    switch ($instance['widget']['type']) {
        case 'my_widget_type':
            $widget += array(
                '#type' => 'fieldset',
                '#title' => t('Masthead'),
                '#element_validate' => array('_module_widget_validate')
            );

            $widget['imagefid'] = array(
                '#type' => 'managed_file',
                '#title' => t('Masthead Image'),
                '#description' => t('The main image to appear for this masthead.'),
                '#default_value' => $values['imagefid'],
                '#upload_location' => 'public://module_name/',
                '#upload_validators' => array(
                    'file_validate_extensions' => array('gif png jpg jpeg'),
                )
            );

            $element['my_widget_type'] = $widget;
            break;
    }

    return $element;
}

function _module_widget_validate($element, &$form_state) {
    $delta = $element['#delta'];
    $field = $form_state['field'][$element['#field_name']][$element['#language']]['field'];
    $field_name = $field['field_name'];
    if (isset($form_state['values'][$field_name][$element['#language']][$delta]['my_widget_type'])) {
        $my_fields = $form_state['values'][$field_name][$element['#language']][$delta];
        $values = $my_fields['my_widget_type'];

        if ($values['imagefid']) {
            $file = file_load($values['imagefid']);
            $file->status = FILE_STATUS_PERMANENT;
            file_save($file);
            if (isset($element['#entity']->nid) && $element['#entity']->nid > 0) {
                file_usage_add($file, 'module_name', 'node', $element['#entity']->nid);
            }
            $values['imagefid'] = $file->fid;
        }

        form_set_value($element, json_encode($values), $form_state);
    }
}

Please assume everything is working except what I'm trying to do with file_usage_add. I realize there may be some aspects that are unconventional (such as the json encoding), but for the requirements of this project, everything is working as intended except in the case of creating new content.

Based on what I've been able to research, a possible alternative approach would be to use file_usage_add with the fid of the file and changing node to file, but I feel like this approach would be incorrect. I have also explored adding a hook_form_submit to process the image after validation, but this seems to be an approach that would be disconnected from my widget.


texts:
I have a new type of content project.

I allowed an anonymous user to add project content in /node/add/project.

I want to add a test before saving node (like the hook_form_validate of webform)

I use hook_node_validate but it's not working

function projects_node_validate($node, $form)
{
  die 'in hook';
}

If this is the right hook, how can I use it?

Thank you


texts: Why are my users are being forced to reset passwords on almost every login?

texts:
After logging out of my site, after about 30 minutes, each user's password is reported to be invalid -- that is, they cannot login with their existing passwords and are forced to use the reset link.

This happens almost every time and happens absolutely every time after a certain period of time.

This is an extremely frustrating problem to diagnose -- I'm not even sure where to start. Any suggestions?

I'm on Drupal 7.50 using a bootstrap 3 subtheme -- heartbeat controls some features.


texts: Fix for "'csrf_token' URL query argument is invalid" error during logout

texts:
I am creating a set of API endpoints for a mobile app using Rest. For User authentication, I am using the default API endpoints supplied by Drupal. That would be

/user/logout?_format=json&token=<logout_token obtained from login api response.>

I wanted to remove the _format=json from the URL parameter and so I created a custom route with the existing controller just for this purpose. However, I am getting an error.

"'csrf_token' URL query argument is invalid

I am not able to figure out how to remove this error. I had added a csrf_token as an additional parameter with the one I got from successful login. It seems however that the csrf token being validated against is generated somewhere else.

I can remove this error by removing the csrf token entry from the routing file entry but that would be a security violation. How do we fix this error or is there a better way to handle the user logout api endpoint.


texts: Why are we using utf8mb4_general_ci and not utf8mb4_unicode_ci?

texts:
Drupal is moving to support utf8mb4, however, it is using utf8nb4_general_ci. Why take the time to move over to support it, and then not fully support it? Is there a specific reason, or just continuing utf8_general_ci from previous?

Would there be any problems with ignoring this and using unicode anyway?

Drupal Ticket:
MySQL driver does not support full UTF-8 (emojis, asian symbols, mathematical symbols)

Here is a question on stack exchange which says really there is no reason not to use unicode now days and finally, on this question, it says "utf8_general_ci is a legacy collation that does not support expansions, contractions, or ignorable characters."

I note that WordPress uses utf8mb4_unicode_ci.


texts: Shortcut menu not showing after admin menu installed

texts:
I have installed the admin menu module and now the shortcuts menu has disappeared.
This is quite confusing


texts:
I'm writing a module that redirects the user on login and am having trouble getting anything to work. Here is what I tried within hook_user_login:

submission.info

name = Submission
description = Handles Redirect to node/add/page on Login
core = 7.x

submission.module

function submission_user_login(&$edit, $account) {
  //$_REQUEST['destination'] = 'node/add/page';
  //$GLOBALS['destination'] = 'node/add/page';
  //$edit['redirect'] = 'node/add/page';
  drupal_goto('node/add/page');
}


texts: How do I change the field value of multiple nodes?

texts:
I'm working on a Drupal project where users can post classified ads. These are simply nodes created using a custom content type.

After 3 months, we want the user who created the node to receive a reminder email. We also need this email to be sent only once.

We're using Rules to send the emails.

This seems simple enough, but the implementation has been very difficult.

Right now, I'm stuck at limiting the number of times the email is sent. I have spent considerable time and effort online trying to find the answer. I still haven't found a straightforward explanation for this task. The closest I've seen is on this forum, which is why I'm asking for your help. It would be greatly appreciated.

= The setup =

There is a "Classified Ad" content type. It includes an "Email" field, and a (hidden) "Email sent?" field.

The user creates a "Classified Ad" node.

Views lists every ad that is more than 3 months old. The View has a VBO field. It also lists the "Email sent?" and "Sticky" values.

The "Send email" Rule is activated when the Cron runs. It has no conditions. It currently has three actions:

Load a list of entity objects from a VBO View. (This loads my list of 3 month old ads.)
Loop. (Loads the VBO list.)

-- Send HTML e-mail. (Sends email to the "Email" field value).

That works. So far so good.

My idea from here would be to add an action in the loop which would change the value of the "Email sent?" field from 0 to 1. I would then filter my View to hide all nodes that have this value.

= The issue =

I can't make Rules loop through my View and change the field value. I know others have had comparable problems and I've tried to apply the suggested answers but I didn't have any success.

I have also tried changing the Sticky value, but no success there either. I can change the first VBO item (at least for some tests), but I can't make Rules loop through all the items to update my nodes.

I have tried various approaches. The latest and (it seems) most promising is to use the Views Rules module. I installed it, created my "Rules" display for my VBO list, and added the Views loop to my Rule.

From there I tested all the combinations of Actions and Data Selectors I could think of to change the field value, but still no success. There were many tests.

Adding a "Set a data value" action inside my Views Rule Loop using "field-email-sent" as Data selector seems the most logical, but then Rules asks for a second Data selector, which makes no sense. When switching to direct input mode, I have to pick a "Node identifier", which makes even less sense. Attempts with other Actions or Data selectors have yielded similar results.

So either my approach is wrong, or one/more of my parameters are wrong. Either way, I need help.

How do I make this work?


texts: Print edit/create/delete node link with jQuery

texts:
Been searching for a while so I came here to ask...

How can I print edit/create/delete node links with jQuery? I just want to show the links when I hover over the < li >'s. I already have the hover code... So I really just need to code to get the edit/create/delete node links.

Edit: So, not the current URL but fetch the ID/NID's. These are in a list. I want to show the edit/delete buttons of that specific article when hovering over an item.

Thanks in advance!


texts: Responsive manually cropped images rendered in twig template

texts:
I have created responsive image style and connected it to 3 different image styles(640x400, 800x400, 1920x500).

I have added an image field into a content type with custom crop format assigned(field's display form) and responsive image as the display format.

If I use drupal's default theme flow all is printed well. However, my goal is to print this out through twig. Any idea on how to succeed on this?


texts: How to create internal and external links

texts:
In drupal 4.x, in contents, links are created like this
[url=1]Some text[/url]
So when "Some text" click it open node 1.

Sometime it may link to external url also. like below:
[url=http://www.abc.com/somepage.html] external link [/url]

same thing how can i do it in drupal 7.x


texts: Remove core and contrib. modules css files

texts:
I would like to prevent several contributed modules from using their own css files. Constantly having to reset their css and then apply your own is a waste of bandwidth IMO.

I tried this out with nice_menus and it didn't seem to do anything.

Placed in template.php

    function phptemplate_variables($hook, $vars) {
        $css = drupal_add_css();

        $rm[] = drupal_get_path('module','nice_menus').'/nice_menus.css';
        $rm[] = drupal_get_path('module','nice_menus').'/nice_menus_default.css';

        foreach ($rm as $key => $value) {
            unset($css['all']['module'][$value]);
        }

        $vars['styles'] = drupal_get_css($css);
    }


texts: Taxonomy fields in node default display using display suite

texts:
I have a content type called "product" and a taxonomy called "producer".
On each product, I can select a producer.
The producer has some fields I need: "country", "area", "district".

I need to display those 3 fields from the producer on the product default display.
How can I do that?

Some things I tried that don't work:

Created a view pane with a contextual filter for term id, then selected the argument input to be "From context" and selected the producer field from the product.
Created a dynamic field in ds and selected the view pane and selected "No being viewd" as the argument.


texts:
I have a long query with sub-queries using db_query().
So far I know SelectQuery of D7 comes with Extenders. Example extenders are PagerDefault (replaces Drupal 6 pager_query()).

I need my query with pager. Can I use PagerDefault with db_query()?
If I have to use db_select() for pager, how can I implement my query with sub-queries using db_select()?

$result = db_query("SELECT leg.*,
    ( SELECT COUNT(*)
    FROM {field_data_field_leg}
    WHERE field_leg_nid = leg.nid AND bundle = :bundle ) AS reviews
FROM
    ( SELECT
        n.nid, n.created, title, field_from_value origin, field_to_value destination,
        field_price_value price, term.name transport
    FROM {node} n
        JOIN {field_data_field_leg} l ON n.nid = l.field_leg_nid
        JOIN {field_data_field_from} ff ON n.nid = ff.entity_id
        JOIN {field_data_field_to} ft ON n.nid = ft.entity_id
        JOIN {field_data_field_transport} t ON l.entity_id = t.field_transport_nid
        JOIN {field_data_field_price} p ON t.entity_id = p.entity_id
        JOIN {field_data_field_transport_type} ttype
            ON t.field_transport_nid = ttype.entity_id
        JOIN {taxonomy_term_data term} ON ttype.field_transport_type_tid = term.tid
    WHERE n.type = :type
    ORDER BY n.created DESC, field_price_value ASC
) AS leg
GROUP BY nid
ORDER BY created DESC",
array(':bundle'=>'review', ':type' => 'leg'));


texts: How to keep class object during form process

texts:
If I have an object (e.g. student object - this is my own custom class)

I would like to initiate this object during 'student registration' form initialization (or form build) and keep the object until I finish with the form (form submitted).

Is there any placeholder for me to hold this object in the FormBase class?
Where I should declare my class? And how to keep the object?

Example in my code:

<?PHP

namespace bla;

use bla
use bla
use bla

class myCreateForm extends FormBase {

  private $student; // i want to initiate this (new student()) and keep until form submit
  /* where i should declare this? and how to keep it? */

  /**
   * Class constructor.
   */
  public function __construct($param) {
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'id_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    //a lot of code here code here
    return $form;
  }

  public function validateForm(array &$form, FormStateInterface $form_state) {
    //a lot of code here code here
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    $output = $this->student->save(); // at the end, i would like to have my own save process which my class will handle it.
    drupal_set_message($output);
  }

}


texts: How do you exclude 'drush' & 'drupal console' requirements from a drupal-composer/drupal-project install?

texts:
When I create a Drupal project with

composer create-project --keep-vcs drupal-composer/drupal-project:8.x-dev myD8 --stability dev --no-interaction

it installs

Latest version of drush is installed locally for use at vendor/bin/drush.
Latest version of DrupalConsole is installed locally for use at vendor/bin/drupal.

I installed & maintain system instances of drush & drupal console.

I don't need the local installs.  I don't want to install them to disk at all.

How do you configure the 'composer create project ...' to not require/install drush & drupal console?


texts:
I'm a newbie to drupal 7 for a year by now. I'm trying to make a unique id field that would increment per node of content type I create.

The computed fields module + serial module is the likeliest method accomplishing my goal, yet I'd like to restart the serial number starting each year, I'm totally lost, please help.

This is the code I've used.
The output: 20150001, 20150002 and so on.
Is there a method to restart the serial num. back to 0001 again when it's a new year?

Computed Code (PHP)

$entity_field[0]['value'] = $entity->field_serial[LANGUAGE_NONE][0]['value'];

Display Code (PHP)

$display_output = date('Y') . sprintf('%04s', substr(str_pad($entity_field_item['value'], 4, '0', STR_PAD_LEFT), -4, 4));

This is another method I've found, it works on the D6 website, but turns into a blank on my D7 published contents. It's from a field on D6 using php filter module.

<?php
$case_id_query=db_result(db_query("select  max(field_case_id_value) as id  from {content_field_case_id} "));

$case_id = date("Y") . sprintf ( '%04s', substr ( $case_id_query, 4, strlen ( $case_id_query ) - 4 ) + 1 );
return array(
  0 => array('value' =>$case_id),
);
?>

can I transform the method above to D7?


texts: Last-Modified header is changed, even if the resource hasn't changed

texts:
Unless I'm mistaken, Drupal is changing the "Last-Modified" HTTP header for a page any time the page cache is regenerated - even if the raw content remains identical.  This means that clients end up having to re-download exactly the same information any time the page cache is regenerated even for pages that have not changed at all.

I realize that I can improve this situation by trying to engineer things such that the page caches are not regenerated unless the resource has changed, but is there any way I can set things up such that the Last-Modified header genuinely reflects whether or not the content has changed?  This would seem to me to be a more robust solution.


texts: How can I programmatically enable clean URLs during a SimpleTest?

texts:
How can I enable clean URLs from the SimpleTest setUp() method?

Which .htaccess will be used during a simpletest?  I needed to make modifications to RewriteBase to get clean URL's working on the 'non-testing environment', will they carry over to the test environment or do I need to modify .htaccess in setUp() as well?


texts:
I have a term migration with an SQL source (WordPress) but the parent term is not properly set when imported into Drupal.
Config:
id: wp_terms_my_terms
label: WordPress Terms: My Terms
migration_group: wp_terms
source:
  plugin: wp_taxonomy_terms
  taxonomy: my_terms
destination:
  plugin: entity:taxonomy_term
process:
  vid:
    plugin: default_value
    default_value: my_drupal_terms
  name: name
  parent:
    plugin: migration_lookup
    migration: wp_terms_my_terms
    source: parent
migration_dependencies: {}

Plugin:
/**
 * Class WPTerms.
 *
 * @MigrateSource(
 *   id = "wp_taxonomy_terms"
 * )
 *
 * @package Drupal\my_module\Plugin\migrate
 */
class WPTerms extends SqlBase {

  /**
   * {@inheritdoc}
   */
  public function query() {
    $query = $this->select('wp_term_taxonomy', 't');

    $query->join('wp_terms', 'n', 'n.term_id = t.term_id');

    $query->fields('t', [
      'term_id',
      'parent',
      'taxonomy',
    ])
      ->condition('t.taxonomy', $this->configuration['taxonomy']);

    $query->fields('n', [
      'name',
    ]);

    $query->orderBy('t.term_id', 'ASC');

    return $query;
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    return [
      'term_id' => $this->t('WordPress Post ID'),
      'taxonomy' => $this->t('Taxonomy Vocabulary'),
      'parent' => $this->t('WordPress Term Parent ID'),
      'name' => $this->t('WordPress Term Name'),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getIds() {
    return [
      'term_id' => [
        'type' => 'integer',
        'alias' => 't',
      ],
    ];
  }

I've verified that the parent value is correctly retrieved in the query via a prepareRow() implementation, so I know the parent ID is correctly being fetched and set on the row, but when the terms are imported into Drupal the vocabulary is flat and no parents are set.
This is especially confusing for me since I've done this successfully before using the same migration_lookup plugin in an SQL based migration in Drupal 8.


texts: How to re-activate the Drupal administrator account that got accidently blocked?

texts:
The admin user account of my Drupal site accidently got deactivated. Because of that, I have no more access to Drupal administration.

How can I change the status of that user account to active again?


texts: How to modify comment-wrapper.tpl.php to change the comment form layout?

texts:
I am trying to change the layout of my comment form. Unfortunately, when I print only fields that I need and the submit button, I can't use the button, nothing happens when I press on it.

I used following code in comment-wrapper.tpl.php:

    <?php print render($content['comment_form']['field_cuisine']); ?>
    <?php print render($content['comment_form']['field_service']); ?>
    <?php print render($content['comment_form']['field_ambiance']); ?>
    <?php print render($content['comment_form']['field_accueil']); ?>
    <?php print render($content['comment_form']['field_qualit_']); ?>

    <?php print render($content['comment_form']['field_nom']); ?>
    <?php print render($content['comment_form']['field_n_de_carte']); ?>
    <?php print render($content['comment_form']['field_e_mail']); ?>
    <?php print render($content['comment_form']['field_t_l_phone_']); ?>
    <?php print render($content['comment_form']['comment_body']); ?>

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

Everything is displayed as expected, but i can't submit the form.

I also tried something like:

    <?php print render($content['comment_form']['field_cuisine']); ?>
    <?php print render($content['comment_form']['field_service']); ?>
    <?php print render($content['comment_form']['field_ambiance']); ?>
    <?php print render($content['comment_form']['field_accueil']); ?>
    <?php print render($content['comment_form']['field_qualit_']); ?>

    <?php print render($content['comment_form']['field_nom']); ?>
    <?php print render($content['comment_form']['field_n_de_carte']); ?>
    <?php print render($content['comment_form']['field_e_mail']); ?>
    <?php print render($content['comment_form']['field_t_l_phone_']); ?>
    <?php print render($content['comment_form']['comment_body']); ?>

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

Like that I can submit the form by pressing on button, but the content of fields are not taken in consideration.


texts: Public URLs have web/ prefix while admins do not, how to remove 'web' prefix?

texts:
I've setup Drupal 8 using https://www.lullabot.com/articles/goodbye-drush-make-hello-composer, but when I visit the site, all the links begin with web/ which means they break. If I remove web/ then they work. If I login, the links don't have web.

How would I remove web/? Where SHould I look in the source tree for a config file or otherwise to adjust this?


texts: How to create a drop down menu for monthly archives?

texts:
I'd like to be able to display a block on the right sidebar with a drop-down menu for the monthly archives ("blog post" content type). Exactly as shown in the following screenshot taken from http://curbed.com/

Can anybody please advise me on how to do this with Drupal 7? Thanks!