我正在用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 - &gt; index.php / home / k2-tags / gallery而不是index.php / home / k2-tags / gallery / my-favorites?state = processing。
Joomla是否有机会覆盖表格?因为我认为这是问题所在。如果有人能给我任何建议,那将非常感激。
答案 0 :(得分:0)
请勿将?state=processing
放入表单的action
属性中。
表格内的某处(最好是在开头或结尾)放置:
echo '<input type="hidden" name="state" value="processing"/>'; // XHTML assummed