Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Using JomGenius with other components to return value

Using JomGenius with other components to return value

Hi Stephen,

Since I don't know much about core language JomGenius seems a really great tool for me to get a bit more intelligent about what I am doing with coding. It can get me to do my work on my own without assistance because of the simplified terms use in the chain of command. I am getting there now and I want to thank you for that.

What I want to do is use JomGenius to query another component such as an helpdesk used for admin only. It contains information about customers and the state of their membership among other things.

This component is called huru helpdesk and uses these URL strings:

Cpanel wrote:

/index.php?option=com_huruhelpdesk&view=cpanel

List problems wrote:

/index.php?option=com_huruhelpdesk&view=list&type=all

List one problem wrote:



I think the list table is in javascript because when I click on a problem I dont get an item ID in the URL but rather this:

/index.php?option=com_huruhelpdesk&view=list&type=all&Itemid=&sort=a

But hovering the items ID in the table list show this as a link:

javascript:detail('xx');

The variable contains 2 or 3 digit numbers that correspond to the problem ID in the phpmyadmin table.

My plan is to query a problem ID and check if certain expression are there and return a value like:

Code:


if ( $core_genius->check( "CurrentMonth != paid" ) )
        echo "This customer did NOT pay this month";

I would echo that answer in a module only seen when admins are logged in. This is possible with a module such as "Custom Code (by JoomlaWorks)".

I wouldn't have much issue coding like that, it would be quite easy and very powerful for a guy like me considering my poor knowledge in coding.

Cheers,
Alex

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Using JomGenius with other components to return value

Hi Alex,

the creation of new JomGenius classes is not a small task, and I'm only doing it for the very biggest of 3rd-party extensions, e.g. VirtueMart, and I have one in progress for JomSocial. Yes, it would be wonderful if there was one for every extension!

What you are attempting above probably needs to be satisfied with 2 things:

1 - retrieving information from the URL about what page you are on, or which item you are viewing
2 - using this information to query the database to find out more information about the status of that item (in the case of a huru_helpdesk case number).

Above, you were wondering about how to get at the URL information, when the URL itself doesn't seem to contain the id of the case number, and hovering over the URL just shows you some javascript.

Here's how:
1 - install MetaMod.
2 - create a new MetaMod and assign it to all pages
3 - turn on MetaMod Advanced Debug mode (in the MM you created)
4 - save it
5 - view pages in the front end, and see the results of the debug mode.

In the case of huruhelpdesk, I logged in as admin and viewed all cases, then clicked on one of the listed cases.

Here's what Advanced Debug mode said:

if (
$option == 'com_huruhelpdesk'
and $view == 'detail'
and $Itemid == '185'
and JRequest::getVar('cont') == 'detail'
and JRequest::getVar('60549a5ac36b35273c73d798543949ce') == '1'
and JRequest::getVar('user') == ''
and JRequest::getVar('cid') == array ( 0 => '1', )
and JRequest::getVar('order') == ''
and JRequest::getVar('task') == ''
and JRequest::getVar('sort') == 'a'
and JRequest::getVar('days') == '-1'
and JRequest::getVar('type') == 'all'
) return XXX; /* replace XXX with the module ID or position to display */


Now, you didn't see most of those variables in the URL! They must have been sent as a POST rather than a GET, so they were hidden.

A lot of those variables are actually useless to you, e.g. the long check code. But you can easily target a module, or write PHP code in the MetaMod, based on the relevant variables.

e.g.
if (
  $option == 'com_huruhelpdesk'
  and $view == 'detail'
  and JRequest::getVar('task') == ''
) {
  $problem_id = '';
  $problem_ids = JRequest::getVar('cid');
  if (is_array($problem_ids) and count($problem_ids) > 0) {
    $problem_id = $problem_ids[0];
    // now you can query the database with this id, here...

  }
}


Now, you could do this with the CustomCode module, but it's probably easier in MetaMod since that gives you immediate access to $option, $view, $Itemid and some others.

I haven't filled out the database query etc, because that would completely depend on how your database is structured and where that information is stored. I'm just trying to illustrate the general point here. You may need to hire someone to help with the rest of the coding.

Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Using JomGenius with other components to return value

Ah! That's a great start! So is the hard work only on the JomGenius classes for a new component?

Can you send me an estimate in USD in PM so I can have a look since you've already checked the component in need classes for?

Cheers,
Alex

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1666
Total Polls:
6
Total Posts:
5909
Dormant:
User Info:
 
Total Users:
10093
Newest User:
lamanaudio
Members Online:
0
Guests Online:
150

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked