I'm currently adapting a shipping plugin that has a form for people to submit their tracking number and shipping company.
The template checks the variable, and if it exists, it generates the proper information for the tracking number and company. If the variable doesn't exist, it shows the form.
basically this
if($ttr<>"") {
All the business logic
} else {
<form method="get">
<input type="text" name="tracknum" />
<select name="company" class="smallForm" id="company">
(...options...)
</select>
<input type="submit"/>
<input type="hidden" name="orderAction" value="track"/>
</form>
}
The original check for this this variable looks like this
if (isset($_POST['tracknum']))
$ttr = $_POST['tracknum'];
else $ttr = $_GET['tracknum'];
So for I put each check in its own variable function, as so
public function ttr()
{
if (isset($_POST['tracknum']))
$ttr = $_POST['tracknum'];
else $ttr = $_GET['tracknum'];
return $ttr;
}
and call it thusly
{% if craft.PluginName.ttr|length %}
All the business Logic
{% else %}
<form method="get">
<input type="text" name="tracknum" />
<select name="company" class="smallForm" id="company">
(...options...)
</select>
<input type="submit"/>
<input type="hidden" name="orderAction" value="track"/>
</form>
{% endif %}
This currently returns
Undefined index: tracknum
Specifically on the line
else $ttr = $_GET['tracknum'];
Now this makes sense to me, as the form hasn't been submitted, so There should be nothing in the $_POST or $_GET. But if that's the case, why does it work on the original website, but not here?
Thanks!