Tuesday, January 5, 2010

Generate Portal using with PHP+MYSQL in Liferay

Implementation Of Portal in Liferay Using PHP:
According to the Post Number 13 from http://www.liferay.com/web/guest/community/forums/-/message_boards/message/214438;jsessionid=D538D102BA519B77651E1B65235D6A23?_19_threadView=flat

Assuming that you install/configure LIFERAY Portal setup in windows machine and Unable to access administration panel like this


STEPS:
1)Here i am using default php portal i.e sample-php-portlet (location c://liferay-portal-5.2.3\tomcat-5.5.27\webapps\sample-php-portlet)
2)Now add below code the index.php after $_POST[];
-------------------------------------------------
//CONNECTION STRING FOR MYSQL DATABASE:
$dbh = new PDO('java:comp/env/jdbc/MySQLDatabase');
if ($dbh) {

$sql="SELECT *FROM emp WHERE name = '".$usr."'";
foreach ($dbh->query($sql) as $row) {
echo "

".$row['name'] . "


";

}

------------------------------------------------------------------------
3)Add Configuration setting at the end tag in
c:\\liferay-portal-5.2.3\tomcat-5.5.27\webapps\sample-php-portlet\WEB-INF\web.xml file
-----------------------------------------------------------------------

DB Connection
jdbc/MySQLDatabase
javax.sql.DataSource
Container

-----------------------------------------------------------------------
4)Add Configuration to map the database to the portal in c:\\liferay-portal-5.2.3\tomcat-5.5.27\webapps\sample-php-portlet\META-INF\context.xml file.
-------------------------------------------------------------------------------
debug="5" reloadable="true" crossContext="true">

maxActive="10" maxIdle="5" maxWait="10000"
username="root" password="kmipl" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8"/>

-----------------------------------------------------------------------------------

NOTE:
If context.xml is not available means, Please add a context.xml under META-INF with above content.

Adding PHP Portal using Liferay Interface.

ADD PHP PORTAL TO LIFERAY SITE


1)Click on the Add Application
2)Select sample-php-portal in the administration section and
3)Click on add link and portal will be enable on the website.

2 comments:

  1. How to install liferay in windows??

    ReplyDelete
  2. Great post, but, what you should do if you want to connect your php portlet to another datasource, different from Liferay's?

    ReplyDelete