How can I get other content type data in current content type? I want to put one condition in my template file of contenttype1. The condition is if contentype2 contains a field value X then I want to print one block in contentype1. So how can I get contenttype2 field values in contenttype1 template file.  To get more clarity, with the contentype2 fields I am creating a views block. I want to display that block in contentytype1 template file. So I want to check a field condition of contentype2. If that field has any value then only I want to display that views block in contenttype1 otherwise it should not display. Thanks in advance for any suggestions.
What you need to do is make X a taxonomy term.

1) Go to taxonomy and create a vocabulary (ex: Colors)

2) Inside Colors vocabulary, add terms. (ex: Red, Blue, Green, Yellow etc..)

3) Go to contentype1 manage fields and add a new field of type: Taxonomy Term Reference. Then select the vocabulary (colors).

4) Now edit your contentype1 nodes and give them a taxonomy term. Ex: Node 1 blue, Node 2 red, Node 3 blue, ...etc

5) Repeat steps 3) and 4) but with contentype2 this time.

6) Create a block view of contenttype2 (You will see it lists all the contentype2 nodes)

7) Under Advanced, add Relationship of Terms of the node, checkmark Colors and checkmark require relationship. 

8) Add a contextual filter of Taxonomy Term and for when filter is not available, set it up like this (using screenshot from another answer):



Once you add the contextual filter, your view preview will go blank, which is normal. Go to a contentype1 node, where you placed the view block, and you should see contenttype2 nodes that have the same taxonomy term as the current contentype1 node that you're viewing.