Is it possible to populate a form when the page loads with the current article, category and section information i.e. page title?
it appears we actually need the information from a previous page π² i.e. if a user wanted to request information about a product (within the article title) then they click a request information button that then takes them to the chrono form - would it be possible to then auto fill a text box for 'product' within the form with the preious pages title?
Is this a javascript function?
Is this a javascript function?
Hi,
The simplest approach here would probably to add the needed information to the link URL. IE: http://www.example.com/index.php?option=com_chronocontact&chronoformname=example&product=Some+Product
or
http://www.example.com/myform.html?product=Some+Product
Then, in your Form HTML code, retrieve the value using the JRequest class and insert it into the desired field:
/Fredrik
The simplest approach here would probably to add the needed information to the link URL. IE: http://www.example.com/index.php?option=com_chronocontact&chronoformname=example&product=Some+Product
or
http://www.example.com/myform.html?product=Some+Product
Then, in your Form HTML code, retrieve the value using the JRequest class and insert it into the desired field:
<input type="text" name="product" value="<?php echo JRequest::getString('product', '', 'get'); ?>" />/Fredrik
That's what I thought, but there's almost 50 pages of items and this would be reflected by the links within the module which is placed on the right of the page.
I think your on the right lines with
I've seen something similar to this to call the information for the page requested, but nothing for the previous page yet.
Any ideas?
I think your on the right lines with
<input type="text" name="product" value="<?php echo JRequest::getString('product', '', 'get'); ?>" />
I've seen something similar to this to call the information for the page requested, but nothing for the previous page yet.
Any ideas?
I've discovered this:
I assume for chronoforms it would be the JScript function?
[ VB ]
Public ReadOnly Property UrlReferrer As Uri
[ C# ]
public Uri UrlReferrer {get;}
[ C++ ]
public: __property Uri* get_UrlReferrer ( );
[ JScript ]
public function get UrlReferrer ( ) : Uri;I assume for chronoforms it would be the JScript function?
Ok well I've fathomed this out, within the table properties under form code then expanding the HTML menu, I amended the code with the addition of 'value="<?php echo @$_SERVER['HTTP_REFERER']; ?>' - this then calls the previous pages url and posts it within the form for me.
So I went from:
to
So yay - but now if I could get the article title that would be even greater - if anyone knows a fix then I'd really appreciate itπ
So I went from:
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Product</label>
<input class="cf_inputbox required" maxlength="150" size="50" title="" id="text_5" name="preqProd" type="text""/>
</div>
<div class="cfclear">Β </div>
</div>to
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Product</label>
<input class="cf_inputbox required" maxlength="150" size="50" title="" id="text_5" name="preqProd" type="text" value="<?php echo @$_SERVER['HTTP_REFERER']; ?>"/>
</div>
<div class="cfclear">Β </div>
</div>So yay - but now if I could get the article title that would be even greater - if anyone knows a fix then I'd really appreciate itπ
Bump bump π just wondering if anyone does know how to parse the page title of the referring page?
Hi,
You could do something like this:
If you simply need the article or category id, you won't have to do the final step of loading the article, as these are already available in $parts['id'] and $parts['catid'], otherwize access the various properties of $article (see http://api.joomla.org/Joomla-Framework/Table/JTableContent.html for details on the JTableContent object and available properties).
/Fredrik
You could do something like this:
<?
$app =& JFactory::getApplication();
if ($app->isSite()) {
if (array_key_exists('HTTP_REFERER', $_SERVER)) {
$router =& $app->getRouter();
$parts =& $router->parse($_SERVER['HTTP_REFERER']);
if (array_key_exists('id', $parts) && array_key_exists('catid', $parts)) {
// We have successfully identified the refering article.. let's proceed
$article =& JTable::getInstance('content');
if ($article->load($parts['id'])) {
// We've successfully loaded the article.. now to print something useful?
echo "You visited this form from the \"" . $article->title . "\" article.";
}
}
}
}
?>If you simply need the article or category id, you won't have to do the final step of loading the article, as these are already available in $parts['id'] and $parts['catid'], otherwize access the various properties of $article (see http://api.joomla.org/Joomla-Framework/Table/JTableContent.html for details on the JTableContent object and available properties).
/Fredrik
This topic is locked and no more replies can be posted.
