Page 1 of 1

Datagrid with Joomla

Posted: Apr 28th, '10, 00:34
by erichhaubrich
Through the use of the 'PHP Pages' component I was able to make the datagrid show up, but when I tried to go to 'Details' or 'Edit' I was sent to the home page of my site. The index.php was appended with ?abc_mode=cancel&abc_rid=9005(etc. etc.) and the datagrid was nowhere to be found.

I'd like to be able to limit access to the datagrid based on the logged in status and permissions in Joomla, but so far I haven't found any good way to integrate datagrid with Joomla where it actually works.

Any help would be appreciated. I think that this would be a very popular script in the Joomla community if it could be made to work properly within the Joomla framework.

Re: Datagrid with Joomla

Posted: Apr 28th, '10, 06:54
by administrator
You have to understand what parameters Joomla passes to this page and say to datagrid that will save them.

For example:

Your url looks like: .....com?act=view&id=2

$http_get_vars = array("act", "id");
$dgrid->SetHttpGetVars($http_get_vars);

Re: Datagrid with Joomla

Posted: Apr 28th, '10, 17:39
by erichhaubrich
The description of how that works is a little vague. Joomla doesn't pass any parameters to the page. Also, if the datagrid is only secured by URL parameters then there really is no security because all anyone has to do is type in the URL with '?act=view&id=2' or whatever. Also, if this did work, how and where would datagrid save the parameters? Also - if incorrect parameters were passed and the website owner did some work on the datagrid, would it be saved?

If possible, could you simplify the explanation and tell me how it would work? Perhaps someone could do a quick tutorial on making datagrid work with Joomla, because right now I haven't found any information that actually does the trick..

Thanks in advance for your help.

Re: Datagrid with Joomla

Posted: Apr 29th, '10, 07:11
by administrator
Are you sure, that Joomla doesn't pass any parameter to access pages?
Give me please one example of your page (not index page) where you don't use parameters.

The standard Joomla link looks like:

Code: Select all

/index.php?option=com_content&view=section&layout=blog&id=7&Itemid=55

So if you are on this page now, you have to save option, view, layout, id, Itemid to stay on this page.
If also about secure pages... Without saving this parameters, you always will be redirected to index.php page.

Re: Datagrid with Joomla

Posted: Jun 6th, '10, 17:40
by HLEBOEUF
Hello,

Could you give me a hint on how to save these parameters. I'm also trying to incoporate phpgrid in a joomla site.
But as i am not really a developper .....

Kind regards

Re: Datagrid with Joomla

Posted: Jun 18th, '10, 13:55
by HLEBOEUF
For people looking for the same problem, this is how I got it working, with the help of the admin.
I'm using Jumi to store my code !!

Code: Select all

<?php
   $thismodule = 2;
   $my = & JFactory::getUser();
   $db = JFactory::getDBO();
   $myid = $my->id;

   if ($myid > 0)
   {
      $db->setQuery("SELECT secu_id FROM `dwe_sec_user` WHERE `secm_id`=".$thismodule." AND `jusr_id`=".$myid." LIMIT 1");
      $result = $db->loadResult();
      if ($result > 0)  /* Just an extra security to check if this user is allowed to run this module, nog all our editors may run all grids */
      {
         header("content-type: text/html; charset=utf-8");

         define ("DATAGRID_DIR", "../datagrid/");
         define ("PEAR_DIR", "../datagrid/pear/");

         require_once(DATAGRID_DIR.'datagrid.class.php');
         require_once(PEAR_DIR.'PEAR.php');
         require_once(PEAR_DIR.'DB.php');

         $DB_USER='xxx';
         $DB_PASS='xxx';
         $DB_HOST='xxxl';
         $DB_NAME='xxx';

         ob_start();
         $db_conn = DB::factory('mysql');
         $result_conn = $db_conn->connect(DB::parseDSN('mysql://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));
         if(DB::isError($result_conn)){ die($result_conn->getDebugInfo()); }

         $sql =   "SELECT ...";

         /* ?option=com_jumi&fileid=3&Itemid=57 */
         $http_get_vars = array("option", "fileid", "Itemid");
         $dgrid->SetHttpGetVars($http_get_vars);


Re: Datagrid with Joomla

Posted: May 30th, '12, 20:09
by robert.elhaddad
Please all your remarks are interesting. But please could you tell us wher to put php source calling datagrid. In Joomla model or Jommla template.

Could you provide us the complexe sample

Thank you

Re: Datagrid with Joomla

Posted: Nov 29th, '12, 20:04
by gavind
Hi HLEBOEUF, that post really interests me but can you please post a sample that you are currently working at production?