View result alter title link based on content type I have view which it has content type filter with more than 1 content type(Eg: A,B). For one specific content type(B) i want to alter the title link to external url(This external url is a custom field in that content type(B) ).

If I alter through Rewrite results using token(custom url),it work fine for the title which comes from B content type, but the title which comes from A content type is going to home page since this custom field is not available in that content type(A). 

Please some one suggest on this.
You can do it via views itself with the little tweaking. 

Since you said the custom URL will not be available in other content types,


Add the required fields including custom field and the content path to your views fields. 

Open the custom URL field and go to No Results Behaviour. Add the Replacement pattern of default content path.

Created a custom text and assembled results. Make sure u refer to custom URL field to link and not the default content URL.



It should automatically work now. Whenever there is no third party URL link not available, it will fetch the default URL. This should have your issue resolved. 

But in case if the third-party URL field was available in all content type with some data, Then you need to do this in preprocess function. This approach will have issues.