Forums

Last visited page parameter not populated

Virzi 08 Sep, 2014
[attachment=2]Schermata 2014-09-08 alle 15.47.25.png[/attachment]Hi everybody,
i'm working on a website i didn't build, and i'm trying to make forms work.
I don't know why, but some time ago we have a form that keeps the $page_name parameter and set it on the db along with the form data, now it doesn't work.

In the form there is a hidden field, you can see the attachment: the field_id is pagina_prov, without a default value

[attachment=0]Schermata 2014-09-08 alle 15.42.04.png[/attachment]

In the events tab, before the db_save, there is a custom code:

<?php
$form->data['pagina_prov'] = $page_name;
?>

[attachment=1]Schermata 2014-09-08 alle 15.44.19.png[/attachment]

And this is the db_save:

[attachment=2]Schermata 2014-09-08 alle 15.47.25.png[/attachment]

Any hint?
Thanks,
Lucio
Max_admin 09 Sep, 2014
Hi Lucio,

But where is the "$page_name" variable set ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Virzi 09 Sep, 2014
Answer
Hi Max, thanks for your response. I solved, the problem was related to a joomla version change, and the variable $page_name was not available anymore. So i hade to put in the hidden field something different:

<?php
$doc =& JFactory::getDocument();
$mytitle = $doc->getTitle();
$form->data['pagina_prov'] = $mytitle;
?>


Thanks a lot,
Lucio
guillome 30 Oct, 2014
How can I store the complete URL in a hidden field?
guillome 30 Oct, 2014
Thanks Bob. How can I get only the URL, not the page title or article title?
GreyHead 30 Oct, 2014
Hi Guillome,

Just use the first example in the FAQ which gets the URL and ignore the rest.

Bob
guillome 31 Oct, 2014
Thanks, it works partly, it only stored the url until index.php but my complete url is:
index.php?option=com_chronoforms5&chronoform=chrono_test
can I store the info after "?" as well?

thanks
Max_admin 31 Oct, 2014
You may also try this code:
<?php echo \GCore\Libs\Url::current(); ?>

Let us know if it works ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
guillome 31 Oct, 2014
this time nothing was stored in the url field, not even the index.php.
guillome 31 Oct, 2014
I solved it. This is the solution:
<input type='hidden' name='page_url' id='page_url' value='<?php echo JURI::getInstance()->toString(); ?>' />
GreyHead 31 Oct, 2014
Hi Guillome.

Well done, thank you - I have updated the FAQ to use that code.

Bob
guillome 31 Oct, 2014
Do you know how to get the right 5 characters of that url and store only that?
Max_admin 31 Oct, 2014
use the PHP substr function:
substr(JURI::getInstance()->toString(), -5, 5);
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
guillome 31 Oct, 2014
and do you know how to get the IP of the visitor?
Max_admin 31 Oct, 2014
These are all PHP questions, please search Google or our forums and you should find quick answers!

Regards,
Max

P.S: the IP of the visitor can be automatically included in the email, you can enable this in the Email settings!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.