Filter Chronoconnectivity from the URL

GMiranda 13 Oct, 2009
Hello,
I have a Chronoconnectivity (CC) wich publishes the records from a Table filtered by a condition (department='name_of_the_department') in the WHERE section.
It's called by a Menu voice.

I need that different Menu voices (relative to the various departments) present the same (CC) applying a diferent condition in the WHERE section.

By now I can make some copies of the same CC, puting in everyone the needed condition manually in the WHERE section.

Is there a way of doing this automatically?
I'm thinking on the possibility of adding a an element to the url of the Menu voice in order to _GET or _POST the element in the CC and use it in the WHERE section.

Something like this:
http://www.website.org/index.php?option=com_chronoconnectivity&Itemid=295&department=name_of_the_department

Does somebody if this or something similar would be possible, and how?

Thanks in advance,
Gonzalo
GreyHead 13 Oct, 2009
Hi Gonzalo,

That should work OK
<?php
$dept = JRequest::getString('department', '', 'get');
switch ( $dept ) {
  case 'department_1':
    echo "WHERE ...";
    break;
 case 'department_2':
    echo "WHERE ...";
    break;
  default:
    break;
}
?>

Bob
GMiranda 13 Oct, 2009
Hi Bob,

For your picture you are GreyHead, but for your support and your tips you are GreatHead! :wink:

I have just applied the code you suggest in the WHERE section. It works perfectly.

At this point I think I must Validate my Chronos...

Thanks a lot.
Gonzalo
GMiranda 27 Apr, 2011
Hi Bob,

I'ts a lot of time I did not come here...
You helped me to get the filter for a table from the URL, with the code you put.

<?php
$dept = JRequest::getString('department', '', 'get');
switch ( $dept ) {
  case 'department_1':
    echo "WHERE ...";
    break;
case 'department_2':
    echo "WHERE ...";
    break;
  default:
    break;
}
?>


I have a problem now:
The CC has a search system, with which the user can choose the records by different criteria.
The problem is that clicking the OK button to apply the search, the URL it writes comes with the only name of the CC, loosing the section I used to get the first filter.
This way, when the table opens the first time, clicking the link it filters by department, but after clicking the OK button the department filter disapears (unlesss the user chooses the department manually: it's one of the applyable criteria).

Is my problem clear?

I think what I need is to know how to put again the department key in the URL when the OK button is pressed.

Than you in advance,
Gonzalo
GreyHead 27 Apr, 2011
Hi Gonzalo,

If you add it into a hidden input then you can carry if forward
<input type='hidden' name='dept_save' id='dept_save' value='<?php echo $dept; ?>' /> 
And in the WHERE box check for both
<?php
$dept_save = JRequest::getString('dept_save', '', 'post');
$dept = JRequest::getString('department', $dept_save, 'get');
?>


This should set $dept to either the URL value if there is one; or the previous saved value if there is nothing in the URL.

Bob
GMiranda 29 Apr, 2011
Hi Bob,

Thank you for your quick and efficent answer.
I'm trying it.

Gonzalo
This topic is locked and no more replies can be posted.