If radio checkbox selected load form/list

Hi,

For some forms/lists we want the companies to get an extra subscription. If they have the subscription .. a radio button will be selected with the value of 1 or yes. This is in the company details.

Now we have some existing pages/lists. I am wondering if it is possible to load a php plugin or calc element, what checks if the radio checkbox is selected or not.

If the radio button is not selected... returning a message... sorry you have the wrong subscription, please follow this link for more information...

and.. not loading the page/list/form.

If the radio checkbox is checked... just load the list/form without problems.

The radio checkbox is in a different table as the form/list what gets visited.

I am thinking to use a php plugin... before form loads... and then.. send the message if needed and kill the rest of loading.

But i am not sure if this can work...

Can someone point me in the right direction in how to achieve this functionallity??

That would really be appreciated.
 
You can create a custom list template for checking the subscription before displaying the list.


Gesendet von meinem SM-G930F mit Tapatalk
 
Ok, let's see if I understand this correct.

I make a new list ... I change the menu to go to that new list first. In the list, i make a query to check the subscription.

If checked, forward to the existing list... if not checked only show message that the subscription is not there.

Is that the way you try to tell me?

And if so, where do I write the query to check for the checked radio checkbox? In a calc element? In a plugin (php) ?
 
You don't need a new list. You can create a custom template and choose this in the menu settings.
(For "security reasons" you should add a prefilter to your list so that users without subscriptions won't see any records if they try to access the list e.g. directly via URL editing).
The query to check would be done in the template (default.php)
...
your query;
if (no access) {echo your message; return;}
...
normal list display
 
Oke,

I made a new template by copying the old template in another folder.

Selected the template in the menu settings. and inserted my code in the whole code

This is my code:

Code:
$user = JFactory::getUser();
$userId = (int) $user->get('id');
$mydb = JFactory::getDBO();
$querycheck = $mydb->getQuery(true);
$querycheck
->select("risico_profiel")
->from("bedrijf_variabelen")
->where("bedrijf_id IN (SELECT bedrijf_id FROM g4e_orakel_personeel WHERE userid = " . $userId . ") OR bedrijf_id IN (SELECT bedrijf_id FROM egocentralis_bedrijven WHERE userid = ". $userId . ")");
$mydb->setQuery($querycheck);
$profielcheck = $mydb->loadResult();
if ($profielcheck !== "1") :
echo '<div class="checkabo"><br /><br />  test123456</div>'; return;
endif;


This is what the code looks like: I made my code in bold so you can see it.


Code:
<?php
/**
 * Bootstrap List Template - Default
 *
 * @package     Joomla
 * @subpackage  Fabrik
 * @copyright   Copyright (C) 2005-2020  Media A-Team, Inc. - All rights reserved.
 * @license     GNU/GPL http://www.gnu.org/copyleft/gpl.html
 * @since       3.1
 */
// No direct access
defined('_JEXEC') or die('Restricted access');
$pageClass = $this->params->get('pageclass_sfx', '');
if ($pageClass !== '') :
    echo '<div class="' . $pageClass . '">';
endif;
if ($this->tablePicker != '') : ?>
    <div style="text-align:right"><?php echo FText::_('COM_FABRIK_LIST') ?>: <?php echo $this->tablePicker; ?></div>
   
<?php
endif;

$user = JFactory::getUser();
$userId = (int) $user->get('id');
$mydb = JFactory::getDBO();
$querycheck = $mydb->getQuery(true);
$querycheck
->select("risico_profiel")
->from("bedrijf_variabelen")
->where("bedrijf_id IN (SELECT bedrijf_id FROM g4e_orakel_personeel WHERE userid = " . $userId . ") OR bedrijf_id IN (SELECT bedrijf_id FROM egocentralis_bedrijven WHERE userid = ". $userId . ")");
$mydb->setQuery($querycheck);
$profielcheck = $mydb->loadResult();
if ($profielcheck !== "1") :
 echo '<div class="checkabo"><br /><br />  test123456</div>'; return;
endif;

if ($this->params->get('show_page_heading')) :
    echo '<h1>' . $this->params->get('page_heading') . '</h1>';
endif;
if ($this->showTitle == 1) : ?>
    <div class="page-header">
        <h1><?php echo $this->table->label;?></h1>
    </div>
<?php
endif;
// Intro outside of form to allow for other lists/forms to be injected.
echo $this->table->intro;
?>
<form class="fabrikForm form-search" action="<?php echo $this->table->action;?>" method="post" id="<?php echo $this->formid;?>" name="fabrikList">
<?php
if ($this->hasButtons):
    echo $this->loadTemplate('buttons');
endif;
if ($this->showFilters && $this->bootShowFilters) :
    echo $this->layoutFilters();
endif;
//for some really ODD reason loading the headings template inside the group
//template causes an error as $this->_path['template'] doesn't contain the correct
// path to this template - go figure!
$headingsHtml = $this->loadTemplate('headings');
echo $this->loadTemplate('tabs');
?>
<div class="fabrikDataContainer">
<?php foreach ($this->pluginBeforeList as $c) :
    echo $c;
endforeach;
?>
    <table class="<?php echo $this->list->class;?>" id="list_<?php echo $this->table->renderid;?>" >
        <colgroup>
            <?php foreach ($this->headings as $key => $heading) : ?>
                <col class="col-<?php echo $key; ?>">
            <?php endforeach; ?>
        </colgroup>
        <thead><?php echo $headingsHtml?></thead>
        <tfoot>
            <tr class="fabrik___heading">
                <td colspan="<?php echo count($this->headings);?>">
                    <?php echo $this->nav;?>
                </td>
            </tr>
        </tfoot>
        <?php
        if ($this->isGrouped && empty($this->rows)) :
            ?>
            <tbody style="<?php echo $this->emptyStyle?>">
                <tr class="groupDataMsg">
                    <td class="emptyDataMessage" style="<?php echo $this->emptyStyle?>" colspan="<?php echo count($this->headings)?>">
                        <div class="emptyDataMessage" style="<?php echo $this->emptyStyle?>">
                            <?php echo $this->emptyDataMessage; ?>
                        </div>
                    </td>
                </tr>
            </tbody>
            <?php
        endif;
        $gCounter = 0;
        foreach ($this->rows as $groupedBy => $group) :
            if ($this->isGrouped) : ?>
            <tbody>
                <tr class="fabrik_groupheading info">
                    <td colspan="<?php echo $this->colCount;?>">
                        <?php echo $this->layoutGroupHeading($groupedBy, $group); ?>
                    </td>
                </tr>
            </tbody>
            <?php endif ?>
            <tbody class="fabrik_groupdata">
                <tr class="groupDataMsg" style="<?php echo $this->emptyStyle?>">
                    <td class="emptyDataMessage" style="<?php echo $this->emptyStyle?>" colspan="<?php echo count($this->headings)?>">
                        <div class="emptyDataMessage" style="<?php echo $this->emptyStyle?>">
                            <?php echo $this->emptyDataMessage; ?>
                        </div>
                    </td>
                </tr>
            <?php
            foreach ($group as $this->_row) :
                echo $this->loadTemplate('row');
            endforeach
            ?>
            </tbody>
            <?php if ($this->hasCalculations) : ?>
            <tfoot>
                <tr class="fabrik_calculations">
                <?php
                foreach ($this->headings as $key => $heading) :
                    $h = $this->headingClass[$key];
                    $style = empty($h['style']) ? '' : 'style="' . $h['style'] . '"';?>
                    <td class="<?php echo $h['class']?>" <?php echo $style?>>
                        <?php
                        $cal = $this->calculations[$key];
                        echo array_key_exists($groupedBy, $cal->grouped) ? $cal->grouped[$groupedBy] : $cal->calc;
                        ?>
                    </td>
                <?php
                endforeach;
                ?>
                </tr>
            </tfoot>
            <?php endif ?>
        <?php
        $gCounter++;
        endforeach?>
    </table>
    <?php print_r($this->hiddenFields);?>
</div>
</form>
<?php
echo $this->table->outro;
if ($pageClass !== '') :
    echo '</div>';
endif;
?>

So if the radio button is not 1... then return the text test123456... and if it is one.. just do the job.

So far so good its returning the text... if value is not 1.

Is this the right approach?

And, how can i get a prefilter doing the right job... because i am not sure how to use this in this case?
 
LOLLLLL I always like this answer... Yes it is working!

can you try to point me towards a good approach of the pre filter... since the radio checkbox is in another table.. how can i prefilter that...

or do I have to do...

where bedrijf_id IN ... (select bla bla from bla bla where risico_profiel = 1
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top