Search Box Not Coming Up With Results - search

I have a search box on my downloads site, where you're meant to type in the name of an application and if I have it on my downloads site, it will come up under the search box.
However, my issue is that when I search anything, it doesn't come up with any results - clarification on what I've done wrong would be appreciated.
<form name="smartForm" method="POST">
<input class="field" type="text" name="app" placeholder="Name of Application">
</select><br><br>
<input class="form_btn" type="submit" value="Search">
</form><br>
<!-- LET THE FORM PHP BEGIN! -->
<?php // gets elements by tagnames
$app = $_POST['app'];
$space = "<br />";
// following code will echo search results
echo '<strong><u>Form Results</u></strong><br />';
echo 'Application Searched: '.$_POST['app'].$space;
// finish PHP
?>

Related

simplesearch modx with date dropdown integration

Iam new to modx(revolution version 2.5.7) and simple search(simplesearch-1.9.2-pl)
I need to add date dropdown (need to fetch results with matching date which is a template variable as type date ) with simplesearch extra in modx plugin. I have attached screenshot of my searchpage for reference. Please help me to solve this.
https://forums.modx.com/thread/95128/advsearch-to-show-search-value-based-on-dropdown-box.
After many painful debugging , got my code working.
[b]My code[/b] ,
[[!AdvSearchForm? &tpl=`AdvanceSearchForm_tpl`]]
</h1>
<h2>Results</h2>
<p>[[!AdvSearch? &parents=`12`&queryHook=`FilterCalenderSnippet` ]]
[b]form tpl (AdvanceSearchForm_tpl) :--[/b]
[code]<form id="[[+advsearch.asId]]_advsea-form" class="advsea-form" action="[[~[[+advsearch.landing]]]]" method="[[+advsearch.method]]">
<fieldset>
<input type="hidden" name="id" value="[[+advsearch.landing]]" />
<input type="hidden" name="asId" value="[[+advsearch.asId]]" />
[[+advsearch.helpLink]]<input type="text" id="[[+advsearch.asId]]_advsea-search" name="[[+advsearch.searchIndex]]" value="[[+advsearch.searchValue]]" />
[[$SeminarCalendarDateChunk]]// give the dropdown of dates,you can put your form elements
[[+advsearch.liveSearch:isnot=`1`:then=`<input type="submit" id="[[+advsearch.asId]]_advsea-submit" name="sub" value="[[%advsearch.search? &namespace=`advsearch` &topic=`default`]]" />`:else`=``]]
</fieldset>
</form>
[[+advsearch.resultsWindow]]
[b]Query Hook snippet(FilterCalenderSnippet)[/b]
[ul]
[li]My Date tv is EventDateTv[/li]
[/ul]
[code]
<?php
$andConditions = array();
// here i need to show events between one given input month. so I did some php to fetch first and last days of given month
if (!empty($_REQUEST['calendar_date'])) {
$dateToTest = $_REQUEST['calendar_date'];// my form element name is calendar_date
$lastday = date('Y-m-t',strtotime($dateToTest));
$andConditions['tv.EventDateTv:>='] = $dateToTest;
$andConditions['tv.EventDateTv:<='] = $lastday ;
}
if (!empty($andConditions)) {
$qhDeclaration = array(
'qhVersion' => '1.3',
'andConditions' => $andConditions
);
$hook->setQueryHook($qhDeclaration);
}
return true;
[/code]`enter code here`

How can I hide whmcs buttons?

Hi I hope someone can help on the client details page I need to hide the Email forwarding button and the DNS management button if the client has selected custom nameservers. I just can't work it out son any help is much welcomed ..Here is the code that takes the input;
<form method="post" action="{$smarty.server.PHP_SELF}?action=domaindetails">
<input type="hidden" name="sub" value="savens">
<input type="hidden" name="id" value="{$domainid}">
<p><input type="radio" name="nschoice" value="default" id="nschoicedefault" onclick="usedefaultns()"{if $defaultns} checked{/if} /> <label for="nschoicedefault">{$LANG.nschoicedefault}</label><br />
<input type="radio" name="nschoice" value="custom" id="nschoicecustom" onclick="usecustomns()"{if !$defaultns} checked{/if} /> <label for="nschoicecustom">{$LANG.nschoicecustom}</label></p>
And here is the code for the buttons;
{if $emailforwarding}
<td><form method="post" action="{$smarty.server.PHP_SELF}?action=domainemailforwarding">
<input type="hidden" name="domainid" value="{$domainid}">
<p align="center">
<input type="submit" value="{$LANG.domainemailforwarding}" class="button">}
</p>
</form></td>
{/if}
{if $dnsmanagement}
<td><form method="post" action="{$smarty.server.PHP_SELF}?action=domaindns">
<input type="hidden" name="domainid" value="{$domainid}">
<p align="center">
{<input type="submit" value="{$LANG.domaindnsmanagement}" class="button">}
</p>
</form></td>
{/if}
I suggest writing a helper function and calling it at the top of the tpl file
and passing the domain id to it.
You can then use the WHMCS internal API function Domain Nameservers to get the domains nameservers then compare them against the default nameservers in the tblconfiguration in the WHMCS database.
Something like this
{php}
// include our helper php file
require_once(dirname(__FILE__).'/Helper.php');
//get domain id from our template variables
$domainid = $this->get_template_vars('domainid');
//call to our helper function passing the domain ID
$hasCustomeNameServers = Helper::hasCustomNameServers($domainid);
//Once we've compared the nameservers agains the default ones we write
//our binary check to the template
if($hasCustomeNameServers >0){
$this->assign('hasCustomeNameServers',true);}
{/php}
Then in side our Helper.php we have something like the following
<?php
class Helper {
public static function hasCustomNameServers($domainid) {
$isCustom = 0;
//Interal API call to get the domains nameservers
$command = "domaingetnameservers";
$adminuser = "admin";
$values["domainid"] = $domainid;
$results = localAPI($command,$values,$adminuser);
//get default nameservers
$defautName1 ='';
$sql = mysql_query('SELECT value FROM tblconfiguration '.
' WHERE setting = "DefaultNameserver1"');
if ($res = mysql_fetch_assoc($sql)) {
$defautName1 = $res["value"];}
$defautName2 ='';
$sql = mysql_query('SELECT value FROM tblconfiguration '.
' WHERE setting = "DefaultNameserver2"');
if ($res = mysql_fetch_assoc($sql)) {
$defautName2 = $res["value"];}
//compare results
foreach ($results as &$value) {
if($value == $defautName1 || $value == $defautName2){
$isCustom++;
}
}
return $isCustom;
}
}
Now it's simply a matter on the template to wrap the {if $emailforwarding} and the {if $dnsmanagement} blocks around our check {if !hasCustomeNameServers}
I hope this helps you in the right direction this is by no means a comprehensive answer but is a guide towards the approach I think you should take in implementing your solution.

Disable empty search

I have a photography site driven in part by the 'Photoshelter' service, and I put an embedded search bar in my nav.
<form action="http://brettcole.photoshelter.com/search" method="get">
<input type="text" placeholder="search library" size="15" name="I_DSC">
<input type="submit" value="go">
<input type="hidden" name="I_DSC_AND" value="t">
<input type="hidden" name="_ACT" value="search">
</form>
It allows for a search to be executed with the no search term present, which then returns all 12,000 photos in my archive. Is there a best practice for preventing this, such that the user has to type something or nothing will happen when they click search?
It's also present on my advanced search page. This is generated by a search widget shortcode in the Photoshelter back end. I'd like to apply the same thing here, but not sure how the widgetization of it might affect the process.
Many thanks
You can use the onsubmit attribute of the form element to check if the user has entered information in any fields and then prevent submit based on that.
<script>
function checkValues() {
searchBox = document.getElementById("SearchField");
return searchBox.value != ""; // True will allow submission and false will prevent it
}
</script>
With this...
<form onsubmit="checkValues();" action="http://brettcole.photoshelter.com/search" method="get">
<input type="text" id="SearchField" placeholder="search library" size="15" name="I_DSC">
<input type="submit" value="go">
<input type="hidden" name="I_DSC_AND" value="t">
<input type="hidden" name="_ACT" value="search">
</form>
Should do what you need.
See also this answer: How to grab the onSubmit event for a form?
The actual search isn't working
From the contact page for example, it returns this
http://brettcolephotography.com/contact.html?I_DSC=red&I_DSC_AND=t&_ACT=search
the formula for my search returns is
http://brettcole.photoshelter.com/search?I_DSC=red&I_DSC_AND=t&_ACT=search
this search bar is present on all three of my web properties, personal site, blog, and photoshelter site, all three are tightly integrated to where you can't tell when you're switching between them. It needs to work regardless of where the search is being executed from. Thanks
Here is a function I wrote to disable the search form submitting if the search field is empty. It also focuses the cursor on the search field if the form is not submitted so that the user does not think that search is broken.
This is assuming that jQuery is loaded. Hope this helps!
var preventSearchIfEmpty = function() {
$('form[method="get"]').on( 'submit', function( ev ){
var query = $('input[type="text"]').val(),
queryLength = query.length;
if ( 0 === queryLength ) {
// Make the cursor blink so user is aware it's not broken, they need input to search
$('input[type="search"]').focus();
ev.preventDefault();
return;
}
});
}();

What is the link to redirect after successful payment at payment gateway in opencart?

I've implemented payment module in Opencart based on BankTransfer module.
Requirement for payment gateway is to submit with get request a successurl and errorurl. Those URL are for successful order and canceled order.
Algorithm:
Customer gets to the order checkout.
Click confirm order
Gets redirected to localhost/opencart/testkzm.php, where values are printed out and there's a link with to which i should redirect in case of success.
QUESTION: What is the link to redirect after successful payment at payment gateway?
Approach:
I've naively thought that http://example.com/opencart/index.php?route=checkout/success is the success link. It's only shows confirmation message, but order is not placed in the system. I understand that there's no way to give external link that will automatically know which order to confirm, so should i pass encrypted unique values in successurl, so on return i can decrypt them and confirm order?
Explanation of files:
banktransfer.php is file opencart gets information from system such
order id, amount of the order and etc.
banktransfer.tpl is template
file for rendering page in browser.(Actual front-end)
testkzm.php is
simple file that i wrote to test that i get correct values from
system.
testkzm.php is
simple file that i wrote to test that i get correct values from
system.
banktransfer.php in controller/payment
class ControllerPaymentBankTransfer extends Controller {
protected function index() {
$this->language->load('payment/bank_transfer');
$this->data['text_instruction'] = $this->language->get('text_instruction');
$this->data['text_description'] = $this->language->get('text_description');
$this->data['text_payment'] = $this->language->get('text_payment');
//Modified things for KZM
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$this->data['orderIdKZM'] = $this->session->data['order_id'];
$this->data['amountKZM'] = $order_info['total'];
$this->data['merchantIdKZM'] = $this->language->get('merchantIdKZM');
$this->data['currencyKZM'] = $this->language->get('currencyKZM');
$this->data['titleKZM'] = $this->language->get('titleKZM');
$this->data['successuUlKZM'] = $this->language->get('successUrlKZM');
$this->data['errorUrlKZM'] = $this->language->get('errorUrlKZM');
$this->data['dateKZM'] = $this->language->get('dateKZM');
$this->data['signstrKZM'] = $this->language->get('signstrKZM');
$this->data['verKZM'] = $this->language->get('verKZM');
//KZM
$this->data['button_confirm'] = $this->language->get('button_confirm');
$this->data['bank'] = nl2br($this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id')));
$this->data['continue'] = $this->url->link('checkout/success');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/bank_transfer.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/bank_transfer.tpl';
} else {
$this->template = 'default/template/payment/bank_transfer.tpl';
}
$this->render();
}
public function confirm() {
$this->language->load('payment/bank_transfer');
$this->load->model('checkout/order');
$comment = $this->language->get('text_instruction') . "\n\n";
$comment .= $this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id')) . "\n\n";
$comment .= $this->language->get('text_payment');
$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('bank_transfer_order_status_id'), $comment, true);
}
}
banktransfer.tpl
<h2><?php echo $text_instruction; ?></h2>
<div class="content">
<p><?php echo $text_description; ?></p>
<p><?php echo $bank; ?></p>
<p><?php echo $text_payment; ?></p>
<p><?php echo $orderIdKZM; ?></p>
<p>
<?php
$titleKZM = $titleKZM.$orderIdKZM;
$merchantIdKZM = '23';
$currencyKZM = 'KZT';
$successUrlKZM = '';
$erroUrlKZM = '';
$dateKZM = $merchantIdKZM.$orderIdKZM.$amountKZM.$currencyKZM;
?></p>
</div>
<div class="buttons">
<div class="right">
<form action="http://example.com/opencart/testkzm.php" method="get">
<input type="hidden" name="merchantIdKZM" value="<?php echo $merchantIdKZM; ?>">
<input type="hidden" name="orderIdKZM" value="<?php echo $orderIdKZM; ?>">
<input type="hidden" name="amountKZM" value="<?php echo $amountKZM; ?>">
<input type="hidden" name="currencyKZM" value="<?php echo $currencyKZM; ?>">
<input type="hidden" name="successUrlKZM" value="<?php echo $successUrlKZM; ?>">
<input type="hidden" name="errorUrlKZM" value="<?php echo $errorUrlKZM; ?>">
<input type="hidden" name="signstrKZM" value="<?php echo $signstrKZM; ?>">
<input type="hidden" name="verKZM" value="<?php echo $verKZM; ?>">
<input type="button" value="<?php echo $button_confirm; ?>" id="button-confirm" class="button" />
</form>
</div>
</div>
<script type="text/javascript"><!--
$('#button-confirm-s').bind('click', function() {
$.ajax({
type: 'get',
url: 'index.php?route=payment/bank_transfer/confirm',
success: function() {
location = '<?php echo $continue; ?>';
}
});
});
//--></script
testkzm.php
merchantID <?php echo $_GET["merchantIdKZM"]; ?><br>
orderID <?php echo $_GET["orderIdKZM"]; ?> <br>
amount <?php echo $_GET["amountKZM"]; ?><br>
currency <?php echo $_GET["currencyKZM"]; ?> <br>
successURL <?php echo $_GET["successUrlKZM"]; ?><br>
errorURL <?php echo $_GET["errorUrlKZM"]; ?> <br>
signstr <?php echo $_GET["signstrKZM"]; ?><br>
ver <?php echo $_GET["verKZM"]; ?> <br>
<div class="buttons">
<div class="right">
asdfas
</div>
</div>
The return URL from the payment gateway is completely up to yourself and the payment gateway's methodology. In general, if you can pass a url to the payment gateway to return for true and/or false for the success of the transaction, you would get it to use a method of your payment gateways controller, such as http://yourstore.com/index.php?route=payment/payment_gateway/success where you can then process the payment, and update the order status accordingly
If you want to then go to the checkout success page, you would use $this->redirect($this->url->link('checkout/success', '', 'SSL')). If it fails, you should redirect back to the checkout pages where the customer can quickly skip through the various pages which should already have their details filled in, and they can then try again
The success url is checkout/success as you thought.
The payment module should confirm the payment before goes to success page. Bank Transfer module do the confirmation by using AJAX (as you can see in banktransfer.tpl) to calls confirm function in banktransfer.php.
It's better if you use another payment gateway module (like pp_standard, moneybookers, paymate, etc) as your starting point instead Bank Transfer because they are more resemble with your custom payment gateway module requirements.
I made this just added simple redirect code to start
<?php
header('Location:http://yoursite location');
exit;
?>
in view/template/yourtemplate/common/success.tpl

Hiding some configurable attribute in the front-end - magento

Please help...anyone
I have a problem with hiding some configurable attributes:
These are my configurable attributes at the back-end:
Shape/Type
Grit & Colour
Shank
Items pack
Diameter
Supplier
My client wants to hide the "Manufacturer" attribute on the front-end
but wants to import the supplier at the back-end.
Please see the website I am working:
http://ridental.com.au/newsite/polishers.html/
I managed to hide it from front-end by just adding some if statement
like this: in the app\design\frontend\default\MYTEMPLATE\template\catalog\product\view\type\options\configurable.phtml
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl class="outer">
<dl class="inner">
<?php foreach($_attributes as $_attribute): ?>
<?php $attCode = $_attribute->getProductAttribute()->getFrontend()->getAttribute()->getAttributeCode(); ?>
<?php if($attCode != "manufacturer"):?>
<div class="dtdd-wrapper<?php if ($_attribute->decoratedIsLast){echo " last";}?>">
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
</div>
<?php endif; ?>
<?php endforeach; ?>
</dl>
</dl>
<script type="text/javascript">
[b]var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);[/b]
</script>
The Manufacturer will not be displayed on the front-end.
But when I click Add to Cart button I got the error:
Please specify the product's option(s).
I noticed that in:
var spConfig = new Product.Config(<?php echo $this->getJsonConfig()
It is still referring to the attribute "supplier" and waiting for the user response to choose Manufacturer in the drop down.
that's why I get the error: Please specify the product's option(s).
My question:
Is it possible to filter the function getJsonConfig()?
let say not include the:
if ($attributecode != 'manufacturer'){
do some stuff.....
}
I copied a local version of this function and now found in: app\code\local\Mage\Catalog\Block\Product\View\Type\Configurable.php
Please help...if anyone accomplished this kind of problem.
I tried extending getJsonConfig() to filter some attribute like "supplier" but to no avail.
Am I doing the right thing?
Chances are, from what you are describing, you should remake the configurable product without using the "Supplier" attribute.
When you make a configurable product, the first screen that allows you to mark attributes with check boxes is meant to define what the configurable product will be filtering, the attributes will still be attached to the product information.

Resources