0

我正在用 PHP 编写一个小脚本,以便用户能够使用 Joomla 插件查询他们在灯箱中拥有的图像。但是,因为我不知道如何创建 Joomla 插件并且需要快速推出此功能,所以我在 Joomla 之外创建了脚本,并将其包含在我需要的地方。

下面是我编写的脚本(尚未完成)。

<?php

    /*
        SETUP SCRIPT WITH JOOMLA SETTINGS
    */

    include('../configuration.php');
    $getConf = new JConfig();

    $config = array(
        'script_url' => '/custom/gallery.php',
        'url' => 'index.php/home/k2-tags/gallery/my-favorites',
        'current_state' => $_GET['state'],

        'host' => $getConf->host,
        'table' => $getConf->db,
        'user' => $getConf->user,
        'pass' => $getConf->password,
        'db_prefix' => $getConf->dbprefix,

        'user_id' => $user->id, // OBTAINED FROM INCLUDER PAGE IN JOOMLA

        'tb_joomla_users' => $getConf->dbprefix . 'users',
        'tb_datso_favorites' => $getConf->dbprefix . 'datsogallery_favorites',
        'tb_datso_master' => $getConf->dbprefix . 'datsogallery'
    );

    echo '<div id="datsocustom">';

    // ADD THE EMPTY GALLERY BUTTON
    //echo '<a href="' . $config['url'] . '"><button style="float:left;">EMPTY GALLERY</button></a>';

    // CHECK WHAT STATE THE SCRIPT IS IN AND ACT ACCORDINGLY
    if($config['current_state'] == '')
    {
        // Show button if state is default
        echo '<a href="' . $config['url'] . '?state=processing"><button style="float:right;">SEND ENQUIRY</button></a>';
        echo '<div style="clear:both;"></div>';
    }
    elseif($config['current_state'] == 'processing')
    {
        // Show ordering form if button is clicked
        if(isset($_POST['order_form'])){
            require('mysqli.php');
            $db = new DB($config);
        }

        echo "<p>Listed below are copies of all the images that you currently have in your gallery. if you'd like us to check the availability of these images please enter the product type and territory.</p>";
        echo "<p>These details will then be emailed to us directly and we will reply as soon as we can with the availability information.</p>";

        echo '<form method="post" action="' . $config['url'] . '?state=processing" style="padding:10px;">';

        echo '<label>Please enter any notes about the nature of your enquiry</label><br />';
        echo '<textarea name="enquiry_info" id="enquiry_info" style="width:100%; height:150px; padding:5px; border:1px solid #CCC; font-size:12px;"></textarea><br />';

        echo '<label>To help us check availability please specify the kind of usage you need for the images in this enquiry</label><br />';
        echo '<label>Product List</label>';
        echo '<select>';
        echo '<option>Default</option>';
        echo '</select><br />';
        echo '<label>Territory</label>';
        echo '<select>';
        echo '<option>Default</option>';
        echo '</select><br />';

        echo '<button type="submit" style="float:right;" name="send_enquiry">SUBMIT ENQUIRY</button>';
        //echo '<input type="submit" style="float:right;" value="SUBMIT ENQUIRY" name="send_enquiry" />';

        echo '</form>';

        echo '<div style="clear:both;"></div>';
    }
    elseif($config['current_state'] == 'success')
    {
        // Show success message if order has processed
    }
    elseif($config['current_state'] == 'failed')
    {
        // Show error message if order has not been processed


        echo '<a href="' . $config['url'] . '"><button style="float:right;">TRY AGAIN</button></a>';
        echo '<div style="clear:both;"></div>';
    }
    elseif($config['current_state'] == 'empty_gallery')
    {

    }

    echo '</div>';

主要问题是,当我在 Joomla 中发布表单时,它会将用户发送到 URL -> index.php/home/k2-tags/gallery 而不是 index.php/home/k2-tags/gallery/my-favorites ?状态=处理。

Joomla 是否有机会覆盖表单?因为我认为这就是问题所在。如果有人能给我任何建议,那将不胜感激。

4

1 回答 1

0

不要放入表单?state=processingaction属性。

在表格内的某处(最好在开头或结尾)放置:

echo '<input type="hidden" name="state" value="processing"/>'; // XHTML assummed
于 2013-06-17T14:39:31.323 回答