Views block displayed by Taxonomy Term which current node, content, page or URL is categorized using Contextual Filters

We all know by now Drupal 7 Views is powerful enough to filter and display dynamically any content in various and flexible ways, and the options are endless. It's just a matter of how and where you want it set up.

Scenario:

  • You have a Content Type (Node), let's say a content type called "Blogs" where content items added may be "Article about Drupal 7", "Article about Drupal 8", "Article about Joomla", "Article about Magento", and list goes on and etc.
  • You have a friendly URL based structure (probably using a Path Auto module generated URL aliases for your content types, content nodes, taxonomy vocabulary and terms)
  • You have a Taxonomy and Terms setup such as: "Blog Category" (Vocabulary), then listed under this are terms such as "Drupal", "Joomla", "Magento", and etc.
  • You want to display all blog contents in your block for this to show on any blog sections, listings or blog pages - no problem you can do that with the filter criteria alone (filtering by Content Type), then under Structure > Blocks adjust this block to show where needed (show in specific URLs only among other choices)
  • You want to display all contents "tagged" or categorized under a specific term in your block

How to Use Contextual Filters to show Blocks dynamically according to Taxonomy Term

  1. Set-up your block to display content, fields, etc. as required - format settings, fields settings, may also include setting up Relationships to show fields from other Content Types, entities, etc.
  2. Under Contextual Filters, add Taxonomy term: Name
  3. Under "When the Filter Value is NOT Available", choose "Provide default value"
  4. Under "Type", choose "Raw Value from URL" - this is due to your requirement to show blocks according to for example /blogs/category/drupal (this URL being the term listing or feed for "Drupal")
  5. In our example, "Path Component" is set to 3, because we want to target the term "drupal" in the URL /blogs/category/drupal (drupal being in the third placement of the URL)
  6. Check "Use path alias"
  7. Save then test by typing in drupal in your preview
  8. Enable the block in Structure > Block, then viola!Drupal-Views-Block-Display-Content-According-Taxonomy-Term.png

How to print custom user field (from user content type) to your node template or tpl file

Original post here https://www.drupal.org/node/1170380#comment-5996382

For author profile info on the node:

How to add and insert a taxonomy term field in Views content display

How to add and insert a taxonomy term field in Views content display
  1. You have a Views for content and it seems inserting a taxonomy term is not available from the field list filter. By default, only options unique or related to Content are available by default, and taxonomy term options seem missing or limited. We need to make these available from the options as well.
     
  2. In your Views page, add a relationship - choose Content: Taxonomy terms on node

Menu modules for no menu links or no menu URL validation

Any Menu Path

https://www.drupal.org/project/any_menu_path

This module allows you to put any relative path you'd like for a menu entry, even if the path doesn't exist on your site.

You might need this module for two reasons.

Drupal 7: How to add custom CSS class to Field Label or Field title

Default Drupal Fields

While it is easy to assign CSS classes to fields in general both field label and value when using Views and when using useful Drupal modules such as the Field Formatter Class module, it is sometimes tricky to insert your custom CSS class to the field label itself.

A quick workaround is to assign a custom CSS class using the field labels value + the field label name. For example to asssign a class to the label of the field - Company Website, you will need to add a class like below: 

[FIX] Drupal Fatal error Call to undefined function dpm in Ubercart (E-Commerce)

In Drupal 7 running UberCart (E-Commerce) module, encountered a Fatal error Call to undefined function dpm
drupal-Fatal-error-Call-to-undefined-function-dpm.png

[Fixed] Drupal 7.5 User warning: The following module is missing from the file system: media_wysiwyg_view_mode

On a Drupal version 7.5x, error suddenly appears: User warning: The following module is missing from the file system: media_wysiwyg_view_mode

It seems the previous version of Media apparently caused the error of the sub-module going "missing". Updating Media module from previous to latest fixed the issue.

Previous version

Views Customize field HTML and Rewrite results UI broken using JQuery, options and selection cannot be enabled, not working

Issues:

When clicking on the options Style Settings > Customize filed HTML and Rewrite Results > Rewrite the output of this field, option is not displaying or expanded

Drupal 7 Image Captioning

Ever wondered how to caption your custom content type Images / Photos, here are some resources I've managed to collect and tried so far:

 

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication.

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file.

Pages

Get reliable web hosting services

Recurring donation

Make Donation

  • Other: $

Donate now

Single donation

Make Donation

  • Other: $

Donate now