Menu

How to show related posts in blogger with thumbnail view

In this post we are going to show you people hot to show related or relevant posts in your blog (Google blogger) with thumbnail view. I tried my best to make it simple and easy so you can easily add make this changes in your blogger and show related posts to your users.

First we will see how this will appear on your blog. below is the screen shot of its appearance.

Related content thumbnail view

Now lets start to achieve this and without and delay show the relevant posts to your users so they can easily find the relevant content and also it will make your site more visible in terms of impression.

Step 1: login into Blogger account and select the TEMPLATE option from the left side of menu.

Step 2: On right panel a preview of your blog will appear showing the CUSTOMIZE and EDIT HTML option. Go with EDIT HTML option.

Step 3: A new coding snippet window will appear. Click inside the code window and then go to find option by press Ctrl+F

Step 4: Search for the text </head>.

Step 5: Copy paste the below code above the tag </head>.
<!--Show related posts in blogger START--><style type='text/css'>
#related-posts{float:left;width:auto;}
#related-posts a{border-right: 1px dotted #eaeaea;}
#related-posts h4{margin-top: 10px;background:none;font:18px Oswald;padding:3px;color:#999999; text-transform:uppercase;}
#related-posts .related_img {margin:5px;border:2px solid #f2f2f2;object-fit: cover;width:110px;height:100px;-webkit-border-radius: 5px;-moz-border-radius: 5px; border-radius: 5px; }
#related-title {color:#333;text-align:center;text-transform:capitalize;padding: 0px 5px 10px;font-size:12px;width:110px; height: 40px;}
</style>
<script type='text/javascript'>
var relatedTitles=new Array();var relatedTitlesNum=0;var relatedUrls=new Array();var thumburl=new Array();function related_results_labels_thumbs(json){for(var i=0;i<json.feed.entry.length;i++){var entry=json.feed.entry[i];relatedTitles[relatedTitlesNum]=entry.title.$t;try{thumburl[relatedTitlesNum]=entry.gform_foot.url}catch(error){s=entry.content.$t;a=s.indexOf("<img");b=s.indexOf("src=\"",a);c=s.indexOf("\"",b+5);d=s.substr(b+5,c-b-5);if((a!=-1)&&(b!=-1)&&(c!=-1)&&(d!="")){thumburl[relatedTitlesNum]=d}else thumburl[relatedTitlesNum]='http://2.bp.blogspot.com/-ex3V86fj4dQ/UrCQQa4cLsI/AAAAAAAAFdA/j2FCTmGOrog/s1600/no-thumbnail.png'}if(relatedTitles[relatedTitlesNum].length>35)relatedTitles[relatedTitlesNum]=relatedTitles[relatedTitlesNum].substring(0,35)+"...";for(var k=0;k<entry.link.length;k++){if(entry.link[k].rel=='alternate'){relatedUrls[relatedTitlesNum]=entry.link[k].href;relatedTitlesNum++}}}}function removeRelatedDuplicates_thumbs(){var tmp=new Array(0);var tmp2=new Array(0);var tmp3=new Array(0);for(var i=0;i<relatedUrls.length;i++){if(!contains_thumbs(tmp,relatedUrls[i])){tmp.length+=1;tmp[tmp.length-1]=relatedUrls[i];tmp2.length+=1;tmp3.length+=1;tmp2[tmp2.length-1]=relatedTitles[i];tmp3[tmp3.length-1]=thumburl[i]}}relatedTitles=tmp2;relatedUrls=tmp;thumburl=tmp3}function contains_thumbs(a,e){for(var j=0;j<a.length;j++)if(a[j]==e)return true;return false}function printRelatedLabels_thumbs(){for(var i=0;i<relatedUrls.length;i++){if((relatedUrls[i]==currentposturl)||(!(relatedTitles[i]))){relatedUrls.splice(i,1);relatedTitles.splice(i,1);thumburl.splice(i,1);i--}}var r=Math.floor((relatedTitles.length-1)*Math.random());var i=0;if(relatedTitles.length>0)document.write('<h4>'+relatedpoststitle+'</h4>');document.write('<div style="clear: both;"/>');while(i<relatedTitles.length&&i<20&&i<maxresults){document.write('<a style="text-decoration:none;margin:0 4px 10px 0;float:left;');if(i!=0)document.write('"');else document.write('"');document.write(' href="'+relatedUrls[r]+'"><img class="related_img" src="'+thumburl[r]+'"/><br/><div id="related-title">'+relatedTitles[r]+'</div></a>');if(r<relatedTitles.length-1){r++}else{r=0}i++}document.write('</div>');relatedUrls.splice(0,relatedUrls.length);thumburl.splice(0,thumburl.length);relatedTitles.splice(0,relatedTitles.length)}
</script>
<!--Show related posts in blogger END-->
Step 6: Again search for the text <div class='post-footer'> and add the below mentioned code before this tag.

<!--Show related posts in blogger START-->
<div id='related-posts'>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.isLast != &quot;true&quot;'>
</b:if>
<script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name + &quot;?alt=json-in-script&amp;callback=related_results_labels_thumbs&amp;max-results=5&quot;' type='text/javascript'/></b:loop>
<script type='text/javascript'>
var currentposturl=&quot;<data:post.url/>&quot;;
var maxresults=5;
var relatedpoststitle=&quot;<b>Related Posts:</b>&quot;;
removeRelatedDuplicates_thumbs();
printRelatedLabels_thumbs();
</script>
</div><div class='clear'/><div style="font-size: 9px;float: right; margin: 5px;">
<a  style="font-size: 9px; text-decoration: none;" href="http://rashidjorvee.blogspot.in/2017/11/how-to-show-related-posts-in-your.html" rel="nofollow" >Grab this Widget</a></div>
<!--Show related posts in blogger END-->
Step 7: Code changes has been completed now you save your template from above SAVE TEMPLATE button.

Note: Go for your site and verify the changes and see how many related posts are appearing in your blog.
If you would like to change the number of related posts and its thumbnail view then go to step 6 and change the value for maxresults=5 to number which you wants.

If you face any issue while implementing this change in your blog, please comment your queries, we will definitely help you.

Can a human become God?

Very complicated question for all humans, but very simple and easy as all well to a person who knows; what are the features of a God? Which makes him God? 
Yes, there is definitely something which compel to human to accept the existence of God. What are those? Did you ever think? I don’t think most of the people think on this topic, that’s why philosopher used to say that religion is a blind faith, and sometimes blindness in religion goes to infinite without limit which became profitable to false saints. Actually we should study and investigate to find our real creator as we do before buying any product or while opting subjects in our study.
Every religion taught us some different aspect to pray our creator, some people consider a magician as a creator, when they saw some magic by that magician, some people are praying to Trees, Sun, Moon, Stars, Animal, Stone, River and Mountain.

But one more interesting thing is that we (human) are the smartest, best and most noble creation of God, do you ever think why human beings are called the best creation of God? I will tell you few features which makes us (human) best in compare to other creation from God.
  1. Only human have an intelligent and powerful brain and also have will power.
  2. A human can have dreams to makes his/her life better.
  3. Only human have skills to survive in any situation.
  4. Only human have ability to perceive what is right and what is wrong.
  5. Without taking help from others we (human) can do anything. Nothing is impossible for a human.


Conclusion: Then why human not use his/er intelligent mind to identify the creator instead of pray and following blindly to anyone or anything.


We need your view as well on this. Please let us know your thought in our comment section.

बुढ़ापा

ये तेल भी एक दिन फुक जाएगा ये सांस भी एक दिन रुक जाएगा
बेड़ा पार उसी का है जो सामने रब के झुक जाएगा
कितनी दुनिया गुजर गई और कितनी और भी आएगी
कितनी है मौजूद यहां पर मौत सभी को  आएगी
ना चढ़ती जवानी पर घमंड करें एक रोज बुढ़ापा आएगा
चलना फिरना होगा मुश्किल टुकड़ा खाट पर खाएगा
ये हुस्न जवानी बस कुछ दिन के तेरी चमड़ी भी सिलवट पड़ जाएंगे
ये रंग तेरा ढल जाएगा फिर बच्चे तुझे चिढ़ाएंगे
तुझे टाइम पर टुकड़ा मुश्किल से और खुद ही मजे उड़ाएंगे 
तू कोई खिदमत इन्हें कहेगा फिर ये तुझे डांटेंगे 
तू बैठा खामोश रहेगा माल तेरा यह बाटेंगे


Aadhaar Act 2016 | Aadhar act section 7

Subject:

 Notification for the use of the Aadhar under the section 7 of the Aadhaar (targeted delivery of the financial and the other subsidies, benefits and the services) Act, 2016 for targeted delivery of financial and other subsidies, benefit and services funded from there from the consolidated fund of India.

1. The use of Aadhaar is identifier to delivery of the services, benefits and subsidies simplify the Government delivery progresses, bring in good governance, transparency and efficiency, and enables beneficiaries to get their entitlements directly to them in a convenient and the hassle free manner. Aadhar obviated the need for producing the multiple documents to provide the identity, etc.


2. The provision of the Other night has come into effect from 12th of September 2016 and notifications to this effect has been published into the official Gazette. To give effect to the provision of the act, UIDAI has approved the regulation under the Aadhaar act which too have been notified in the official gazette. The copy of the act, rule and regulations made there under are available at the UIDAI website.


3. Section 7 of the act provides:


 The Central Government or, as the case may be, the State Government may, for the purpose of establishing identity of an individual as a condition for receipt of a subsidy, benefit or service for which the expenditure is incurred from, or the receipt therefrom forms part of, the Consolidated Fund of India, require that such individual undergo authentication, or furnish proof of possession of Aadhaar number or in the case of an individual to whom no Aadhaar number has been assigned, such individual makes an application for enrolment: Provided that if an Aadhaar number is not assigned to an individual, the individual shall be offered alternate and viable means of identification for delivery of the subsidy, benefit or service.


4. Further, regulation 12 of the Aadhaar enrollment in the update regulations 2016 provides
Any central or state department or agency which requires an individuals to undergo the authentication or furnish proof of possession of the Aadhaar number as a conditions for receipt of any subsidy, benefit or services pursuant to section 7 of the Aadhaar Act, shall ensure enrollment of its beneficiaries who are yet to be enrolled, through the appropriate measure including coordination with registrars and setting up enrollment centers at convenient location for providing enrollment facilities by becoming a  registrar itself.


5. Therefore Central Ministries and state governments which plan to use the Aadhaar for the delivery of the services, benefits and the subsidies funded from the consolidated fund of India are required to issue a notification under the section 7 of the act. Section 7 of the act read with regulations 12 of the Aadhaar enrollment and update regulations 2016 is required at the notifications must include all of the following three points:

5.1 The notification cell mention the service, benefits or subsidies funded from the consolidated fund of India, which will require as a conditions precedent a beneficiary applications to undergo the Aadhaar authentication or furnish proof of position of Aadhaar number.
5.2 This notifications shall mention that in case of the applicant does not have the Aadhaar number, he will be required to make an applications for the Aadhar enrollment, if he is entitled to obtain one under the section 3 of the act and the arrangement made by the concerned central ministers or state governments as the case may be to provide the Aadhar enrollment facilities to him. Regulation 12 of the said regulations cast the responsibility of the ministers and their state governments or agencies under their control to facilitate and provider enrollment facilities at convenient location. In case there are no existing enrollment facility nearby, they are required to become UIDAI Registrar so that they can set up enrollment facilities themselves.
UIDAI has already empowered the several Central ministries and state departments or agencies under their jurisdictions to become its registrar and the undertake enrollment of their beneficiaries who are not enrolled for the Aadhaar. UIDAI I will continue to provide all technical as well as financial assistance for Aadhaar generation @ rupees 40 per Aadhaar and @ rupees 27 per Aadhaar generated for the children of the age less than 5 years through tablets computers. In case any ministry, state government department or agency under its control want to become the registrar, is may do so immediately by applying under the regulation 21 of the said the regulations and contact the regional offices of the UIDAI for this purpose.
5.3 The notifications and list the alternate identity documents and the verification methodologies to confirm the Identity of the beneficiary applicant to whom Aadhaar number has not been assigned for delivery of benefits, subsidies, or services, till such time Aadhaar number is assigned.



References:

Cannot make a static reference to the non-static method

Cannot make a static reference to the non-static method display(String) from the type RunAndTest.
We cannot access or call a non static method or variable from a static method or main method(which is also a static method) of a class. Since non-static method and variables belongs to the instance of the class and we call them instance variable and method, but static method and variable are directly belongs to class which we called member variable and method.
We can access a non-static variable and method in static method only using the instance of the class. But if you want to access any non-static variable and method in non-static method of the same class then we can access them without instance of the class.


Why we can not access? 

As soon as our program loaded into memory at the same time all static variable, method and block get loaded in the memory as well, and JVM will maintain only single copy of those static thing through all over the class. And all non-static components will get loaded into the memory when we create instance of that class that why we called them instance variable/method, and when you create another instance of that class then a new and separate memory will be get allocated for all those variables and methods for that instance.

In case if you will write a code to access a non-static member in static method without instance of that class then compiler will through the error "Cannot make a static reference to the non-static method".

Below is a code sample which you could just copy and paste in your IDE and understand the concept of this static and non-static.

Compilation fail while accessing a non-static method in static method.


package coreJava;
public class RunAndTest {
public static void main(String[] args) {
display("string"); //This line of code will through compile time error "cannot make a static reference to the non-static method display(String) from the type RunAndTest"
}
void display(RunAndTest rt){
System.out.println("Test");
display("sdj");
}
void display(String string){
System.out.println("String method");
}
}

Access a non-static method in static method, with the help of object of the class.


package coreJava;public class RunAndTest { public static void main(String[] args) { RunAndTest rt=new RunAndTest(); rt.display("string"); 
} void display(RunAndTest rt){ System.out.println("Test"); display("sdj"); } void display(String string){ System.out.println("String method"); }} 

How to set property of a bean from external source file using Spring framework

Today in this tutorial we are going to discuss how to set property of a bean from external source file using Spring framework.

As we already know Spring is a very powerful framework to inject the dependency at get the value at run time in the form of beans. But what happen if we don't have value for those beans in our ApplicationContext.xml file and we need to fetch value from some external file or data source and assign those values to beans. We will see these all in a sample example program.

Files used in this example:


  1. Apple.java
  2. myApp.properties
  3. AppContextRashid.xml
  4. ClassHer.java


First we will create a java POJO calss "Apple.java" in this class we will create two String variables and their getters and setters. Also we will create a method whoareyou() with return type String.
Below is the code:
package rashidtest;
public class Apple  {
String name1, desc1="not yet set";
public String getName1() {
return name1;
}
public void setName1(String name1) {
this.name1 = name1;
}
public String getDesc1() {
return desc1;
}
public void setDesc1(String desc1) {
this.desc1 = desc1;
}
public String whoareyou() {
String result= name1 + desc1;
if(desc1 == null) return name1;
else if(name1 == null) return desc1;
else return result;
}
}

Second we will create a property file which contains the value for name1 and desc1 variables. to do so we will create a file "myApp.properties" in a xmlBeans package in our source directory which have some values. below is the example file.

def-desc=I am a fruit and my color is Red.
def-name=Apple.

Third we will create a xml bean file "AppContextRashid.xml" in which we will to include namespace "xmlns:context="http://www.springframework.org/schema/context" to read the data from external source.

To read the external property or value from file we will provide the location in property placeholder. e.g. <context:property-placeholder location="xmlBeans/myApp.properties"/> 

Then in Bean property tag we will assign values from file to POJO class variables. To get the value from properties file we will write "${name of the property}". 
e.g. <property name="desc1" value="${def-desc}"></property> 
In the above statement we are fetching value for property "def-desc" from .property file and assigning its value to "desc1" variable in Apple class.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<context:property-placeholder location="xmlBeans/myApp.properties"/> 
<bean id="apple" class="rashidtest.Apple">
<property name="desc1" value="${def-desc}"></property>
<property name="name1" value="${def-name}"></property>
</bean>
</beans>

Fourth and final we will create a implementer class which have main method, instance of ApplicationContext and inject the value from bean to class using setter injection. to achieve this we will create a java file "ClassHer.java". Below is the complete class.

package rashidtest;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class ClassHer {
public static void main(String[] args) {
ApplicationContext appContext=new ClassPathXmlApplicationContext("rashidtest/AppContextRashid.xml");
Apple apple=appContext.getBean("apple", Apple.class);
System.out.println("Apple class have property: " +apple.whoareyou());
}
}

What is Smog and how to prevent from this?

Smog is a type of air pollution. Smog is also used to describe the type of fog which has smoke or soot in it. Smog is a blackish fog formed mainly by a mixture of pollutants in the atmosphere which consists of fine particles and ground level ozone. Smog has smell as well. Smog is basically mixture of gases with dust. Smog increases in atmosphere due to burn the crops, vehicles, industrial plants and heating due to some other source.

Problems which you could face due to Smog?

Smog may cause some critical health problems such as asthma, cough,  emphysema, chronic bronchitis and other respiratory problems as well as eye irritation and reduced resistance to colds and lung infections. Also our plants and crops get impacted from this.


How can you protect yourself from Smog attack? What are the prevention to protect yourself from Smog?

If you are a child below the age of 10 and old person above the age of 55 then you should not go outside in open. In case you have to go outside use eye protection(glasses which hide your eyes) and mask which hide your Mouth and Nose. This will became very serious for patients who are suffering from asthma and any other illness related to Breathing.
  1. Frequently wash your hand and face.
  2. Eat fresh vegetables and oily foods.
  3. Wash fruits and vegetable very well before serve.
  4. Apply mask and glasses.
  5. Avoid going outside.
  6. Use air purifier.

What is Sling and why have multiple scripts/renderers for a Component?


Apache Sling is one of the technology stack of AEM/CQ5 CMS on which AEM is built on. Sling is a Web application framework based on REST principles that provides easy development of content-oriented applications. In general terms we can say Sling is used to resolve the resources or URI in our application. Sling uses a JCR repository, such as Apache Jackrabbit or Day's CRX, as its data  store.
Sling maps HTTP request URLs to content resources based on the request's path, extension and selectors.

The Resource is one of the central parts of Sling. Extending from JCR, Everything is Content, and Sling assumes that Everything is a Resource.

Apache Sling is included in the installation of CQ5. Sling has since been contributed to the Apache Software Foundation - further information can be found at Apache Sling.
Using Apache Sling, the type of content to be rendered is not the first processing consideration. Instead the main consideration is whether the URL resolves to a content object for which a script can then be found to perform the rendering. This provides excellent support for Web content authors to build
Pages which are easily customized to their requirements.
The advantages of this flexibility are apparent in applications with a wide range of different content elements, or when you need Pages that can be easily customized/viewed differently.


How sling used to resolve a URL (Resource) in AEM? and How sling works internally?

The following diagram explains the Sling script resolution. It shows how to get from HTTP request to content node, from content node to resource type, from resource type to script and what scripting variables are available.

how sling resolve a resource in AEM. Adobe CQ, AEM sling resource resolver, how sling works.
Sling Resource resolver


The following diagram explains all the hidden, but powerful request parameters you can use when dealing with the SlingPostServlet, the default handler for all POST requests that gives you endless options for creating, modifying, deleting, copying and moving nodes in the repository.

We will now see how sling resolve a URL by using the above resolution diagram.

1. Actual URL get divided into the following chunks. e.g. we have a URL " www.rashidjorvee.blogspot.com/blog/post/aboutrashid.print.html/printable?height=400,width=200" and now we will see how sling will resolve my URL.
  • Request Method: This information comes in request header.
  • Content Path: [/blog/post/aboutrashid] 
  • Seletor: [print]
  • Extension: [html]
  • Suffix:
  • Query parameter : [height=400,width=200]
2. Sling will go to the requested content path.

3. Then it will check whether that content path or component has property sling:resourceSuperType or sling:resourceType. If request found any of these property in that node then sling request move to that path which is present in the sling:resourceType or sling:resourceSuperType.


sling:resourceType is used to render to script files.

sling:resourceSuperType is used to overload or inherit a existing component.



4. Then render to the path given in resourceType and resourceSuperType property to load the script or inherit the functionality. To resolve this first sling will find the path under apps directory, in case that content path is not available in apps then request will move under libs directory. 


5.  In this step sling will look for script name and try to match with the exact request URL with requested selector and extension. There is a set of rules which sling follow to match the selector and extension. Following are the rules:

  • Folders (i.e. nodes of type nt:folder) take precedence over jsp file names when resolving using selectors, at least for the first selector.
  • Only one selector in a file name has any effect - any files with names containing two selectors don't ever get selected, but names of folders can be used to match the selectors in the request.
  • Scripts with HTTP method names (e.g.,GET.jsp) is selected as a last resort, (after the default script: jobs.jsp, in this case).
  • Scripts with names that include HTTP methods in addition to another selector or extension in a .jsp file name are never selected.



Ibtadaye ishq hai rota h kya

Ibtadaye ishq hai rota h kya 
Age age dekhye hota h kya

Neend ab tere mukaddar me nhi
Raat ki pichhle pahar sota h kya

Ibtadaye ishq hai rota h kya 
Age age dekhye hota h kya

Ye nishane ishq hai jate nhi
Daagh chhati ke abas dhota hai kya

Gir ke uthna uth ke chalna sikh le
Baghe manzil is tarah hota h kya

--- Meer Taqi Meer