Overgive Compnent Title to Chronoform and sent it

adamf 24 Apr, 2013
Dear Chronoforms forum,
i have a little problem to overgive a joomla variable to my form. I have a module in which is posted a img which links to my form. Now I only wanted to use one module with one link and one php code to sent the article title to my form. I have seen a lot of topics in this forum to overgive a variable, but it didn´t worked for me. I use joomal 2.5.9 with Chronoforms 4.0 RC3.5.2. I could read the site title with this code (I copied it from an other page):
<?php
function getMenuItemByLevel($id = 0, $level = 1)
{
	$app = JFactory::getApplication();
	$menu = $app->getMenu();
	if($id == 0)
	{
		$id = $menu->getActive()->id;
	}
	$item = $menu->getItem($id);
	if($item->level > $level)
	{
		return getTopLevelItem($item->parent_id, $level);
	}
	elseif($item->level == $level)
	{
		return $item;
	}
}
?>

<?php 
$toplevelitem = getMenuItemByLevel(0, 1);
echo $toplevelitem->title;
?>

but i dont know how to overgive it to Chronoforms, from a link. Normally in general php you use get or post which using an php file which displays the result, but i want to read the title in the link, overgive it to Chronoforms, display it there in a field and sent it via email. So if there is somebody out there, who knows the trick, please tell me.
Thank you 😀
adamf 25 Apr, 2013
Hello Bob,
thanks for your fast reply, iam really impressed. Sorry i didn´t find the solution in the FAQ, but i read a lot of post from you inside the forum. I will try it out and post my experience with it.
Thank you :wink:
Kindest Regards Adamf
adamf 05 Jun, 2013
Hello Bob,
the php solution didnt work for us so we solved it with js, but again thank you for your fast answer and your tipps.
For all who also have the problem and dont find a solution, we solved it with java script, maybe it helps you too. It might be not very clean but it works for us. This Solution we integrated into Joomla 2.5:

First the content:

<p><a id='linkContact' ><img style="margin-bottom: 10px;" src="e.g. your image or you link text" width="230" height="29" /></a></p>


this is the script you have to post direct under the content (we integrated the code in the database):
<script>
var a2 = document.getElementById('linkContact');
var elements = document.getElementsByClassName("item-page detail");
var value1  = elements[0].innerHTML.substring(0,elements[0].innerHTML.indexOf("</h1>"));
value1 = value1.replace('<h1>','');
a2.setAttribute('href',"kontakt.html?title=" + value1);
</script>


This script for the content you can also put into the Database, you only have to find the table with your content e.g.:
</p>\r\n<p><a id=''linkContact'' ><img style="margin-bottom: 10px;" src="e.g. your image or you link text" width="230" height="29" /></a></p>\r\n<script>\r\nvar a2 = document.getElementById(''linkContact'');\r\nvar elements = document.getElementsByClassName("item-page detail");\r\nvar value1  = elements[0].innerHTML.substring(0,elements[0].innerHTML.indexOf("</h1>"));\r\nvalue1 = value1.replace(''<h1>'','''');\r\na2.setAttribute(''href'',"kontakt.html?title=" + value1);\r\n</script>', 1, '', 905, '2013-05-03 08:49:27', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 1, 'mod_custom', 1, 0, '{"prepare_content":"1","backgroundimage":"","layout":"_:default","moduleclass_sfx":" box2","cache":"1","cache_time":"900","cachemode":"static"}', 0, '*'),


Then you go to your form you created before, and go to code, custom and insert this behind the chronoforms code :

e.g.
this is my created field for the code in chronoforms:
<div class="ccms_form_element cfdiv_text" id="input_text_71_container_div" style=""><label>Betreff:</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="input_text_7" />
<div class="clear"></div><div id="error-message-input_text_7"></div></div>


and this the code:

<script type="text/javascript">// <![CDATA[
var title	= getPara('title');
document.getElementsByName("input_text_7")[0].value = title;
if(title!="")
document.getElementsByName("input_text_7")[0].disabled = true;
function getPara(name){
	if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
      return decodeURIComponent(name[1]);
}
// ]]></script>


Now the title will be overgiven by get method and switches from site to chronoform. A cleaner solution would be to write the code in e.g. a selfmade module.

Hope I could help the helpless and thanks to Bob, great guy.

Cheers AF
This topic is locked and no more replies can be posted.