Monday, August 5, 2013

IFRAME problem with IE

Hi guys,

I experienced there is a problem with 'Iframe' tag especially with IE(Internet Explorer). The problem is, IE not allow third party cookies. Hence you may get problem with functionality with Iframe.

Ex: If you are working for www.yoursite.com  and want to use feature of other site using iframe, you may write code like as below,
<iframe src="www.anothersite.com" /> 

The problem is when your site loaded, cookie will be stored in the browser.In the same page or site you are trying to call another site's content, so that page cookie will be third party cookie for browser. Some times its not allowed in IE.
This you can check with the 'Evil eye' icon in the bottom of your browser.

So there i simple way where you can set cookies and make your page safer('Safer' because even if you are not using privacy statement for your site, you can get rid of cookie problem).

Solution:

Use p3p, in all you site by including below line in starting of your page which all are in Iframe.

response.setHeader("P3P","CP='IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT'")

 That's all .......!

Thanks to Viral Patel.

If you are using PHP or other language you can go through this post: Iframe problem with IE

For more information for CP parameters you can go through this post: P3P possible parameters


Regards
Praveen Pujar

Wednesday, June 26, 2013

Detection of first time visitor to the website using jquery.

Hi guys,


Today I was working with one requirement, in which I would find the first time visitor to my portal/website(I am using Liferay portal for website) for some business needs. Lets say to Wish like welcome note with beautiful picture or like asking user to agree terms and condition before going opening website, etc, etc.... I think most of the time we need this feature. Hence I am writing this posts, may be useful for somebody.


HOW TO DETECT FIRST TIME VISITOR TO THE WEBSITE???????

If we are using any web technologies or I would say smart frameworks like LIFERAY, we can make use of Jquery code to detect. So how???? Lets see how we can do in Liferay using themes, using Jquery in it. 

  • If you are using your custom theme, you can add the jquery code in main.js file. Which you can find in <theme-name>/docroot/_diffs/js/main.js
  • lets write jquery code, we can make use of cookies.
            lets give the cookie name to your site as  "myCookie", lets set the cookie name.
           
 if(!($.cookie('myCookie')))
  {
      alert("Welcome, Thanks for visiting");
      $.cookie('myCookie','visited', { path: '/', expires: 10000 });
  }
else
 {
     alert("Already visited.");
 }
That's all guys. Use the above code in main.js of your theme and you can detect the first time visitor.
IMPORTANT NOTES 
  1. To work with cookies of Jquery you should have the jquery.cookie.js plugin. You can find that in   jquery.cookie.js
  2. If you want to know more about attributes I have used for cookies you can go through Cookies Properties



Friday, October 19, 2012

Adding custom field in registration page is Liferay

Hi, guys Liferay is such a beautiful portal technology, it has one pretty nice feature about custom fields.

This post is how to use that custom field feature in registration field in liferay

Here are the steps to be followed
1. Click on control panel > User > Custom attributes > Add Custom attributes.

2. Here we need to give a key (name) and type of the field.  

3. For eg. We will have an Field called Designation added which is a text field. 
    Key :   Designation
    Type : Text-field(Indexed) and save. 

4. Then add the custom attribute taglib in the create_account.jsp in /tomcat/webapps/ROOT/html/portlet/login as follows:

<liferay-ui:custom-attribute-list

            className="com.liferay.portal.model.User"

            classPK="<%= 0l %>"

            editable="<%= true %>"

            label="<%= true %>"

      /> 
    But this field will not appear on the create account page because permissions are not given.


   Hence to permission click on action tab of that custom attribute(here eg.Designation) and permissions

 Note: very important thing is assigning permission for added custom field to guest

    1. Here for guest we give permission for view and update.
  
    2. Now in the create account page this field will appear.


And you can get those value in expando table in liferay, you can fetch the value using expandoBridge class.