Keyword

Insert k2 item title and author email in rsform pro module

  • jorge mejia gallegos
  • jorge mejia gallegos's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 7 months ago #94450 by jorge mejia gallegos
i would like to have a rsform module in all my k2 items that autopopulates the subject and to fields with the k2 title and Authors email. so that users can get in touch with the item author.

In rsform i can populate the From field with the user email if logged in with the following code:

//<code> $user=&JFactory::getUser(); return $user->get('name'); //<<code>

How can i do the same to get the Title and Email from the context of the K2 item page.

i have been searching for quite a while for a solution but haven't found anything yet, any help will be much appreciated.

 

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #94451 by william white
Take a look here

Since 'name' is a variable and

'email' is also in the list, they are both strings try call it in the same manner as you are using for name

Please Log in or Create an account to join the conversation.

  • jorge mejia gallegos
  • jorge mejia gallegos's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 7 months ago #94452 by jorge mejia gallegos
Replied by jorge mejia gallegos on topic Insert k2 item title and author email in rsform pro module
Thank you for your reply,

As a matter of fact im already using the email variable to autopopulate the from field taken from the logged user info, but what im trying to achieve. is to send the email to the Author of the K2 item where the rsform is being displayed, and autopopulate the subject field with the K2 item Title.

i have tried using $this->item->params->get('itemTitle') but it doesn't seem to work outside the item.php

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #94453 by william white
At some point you have the item up and going. I would set a global variable of some sort there, and then try to reference it in the form

Please Log in or Create an account to join the conversation.

  • jorge mejia gallegos
  • jorge mejia gallegos's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 7 months ago #94454 by jorge mejia gallegos
Replied by jorge mejia gallegos on topic Insert k2 item title and author email in rsform pro module
i have tried setting a global variable. my programing skills are very basic, so i looked around to figure out how to do it, i found this article php.net/manual/en/language.variables.scope.php and tried to follow it but wasnt succesful.

so this is what i did, i went to item.php and added something like:

<?php $xxx = $this->item->title; ?>

then went to my form and did:

//<code>

$yyy = $xxx;

return

$yyy;

//<code>

i did some variations like:

//<code>
<span style="color: #000000;"><span style="color: #007700;"><span style="color: #000000;"><span style="color: #007700;">global $yyy;<br/></span></span><br/></span></span>

$yyy = $xxx;

return

$yyy;

//&lt;code&gt;

or

//&lt;code&gt;

$yyy =
$GLOBALS['xxx']
;

return

$yyy;

//&lt;code&gt;

But i stll got no result. Maybe you can see what im missing.

thanks again for your help

 

 

 

Please Log in or Create an account to join the conversation.

  • jorge mejia gallegos
  • jorge mejia gallegos's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 6 months ago #94455 by jorge mejia gallegos
Replied by jorge mejia gallegos on topic Insert k2 item title and author email in rsform pro module
no more thoughts on this subject?

Please Log in or Create an account to join the conversation.

More
13 years 2 months ago #94456 by Dario Pintarić
Same problem here....

I'm using JAT3 and K2, and tryed just about anything to get the item name (article name) into a rsForm hidden field... the value of the hidden field just ends up empty.... like it never processed the code....

Btw. u get the oint of doing this ? One form in all articles with recorede Itemname (article name)...

So.... anyone ? any help ?

Please Log in or Create an account to join the conversation.

  • jorge mejia gallegos
  • jorge mejia gallegos's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 2 months ago #94457 by jorge mejia gallegos
Replied by jorge mejia gallegos on topic Insert k2 item title and author email in rsform pro module
i know! i have a bussines directory with k2 and i wanted to have a form on every item to contact the bussines owner. at first i tried to have a  single rsForm mudule for all my pages and autopopulate the "to" and "subject" fields with the k2 item creator email and title. but i could not figure it out and could not find any help.

so what i ended up doing is using the System - RSForm! Pro  Plugin to insert the form {rsform 1} in the k2 item.php and then used javascript to insert the values into the form´s hidden fields. like this:

&lt;!-- Contact Form --&gt;    &lt;div id="contactForm"&gt;

    &lt;script type="text/javascript"&gt;     function setFormField( idRef, val ) {      if(!document.getElementById ) return;      var inputObj = document.getElementById( idRef );      if( inputObj ) {      inputObj.value = val;      }     }     &lt;/script&gt;  

    &lt;?php $document-&gt;addStyleSheet('components/com_rsform/assets/themes/your/green/style.css'); ?&gt;

    {rsform 12}

    &lt;script type="text/javascript"&gt;     setFormField( 'subject', '&lt;?php echo $this-&gt;item-&gt;title; ?&gt;' );     &lt;/script&gt;

&lt;/div&gt;&lt;!-- End Contact Form --&gt;

 

it did the trick for me... i hope it helps you

 

Please Log in or Create an account to join the conversation.

More
13 years 2 months ago #94458 by Dario Pintarić
OK, i tried echo-ing the echo $this-&gt;item-&gt;title; and i works, so it's obvious it works only from the k2 component files, because i tryed it drom the template itself and it returns nothing....

However i tried paste-ing your script and it doesn't work, or should i say - id have no idea what to modify... Javascript is a completly another unsresearched world for me. So if you could plz tell me how modify it ?

I have a hidden filed with name "UrlNameFromPage", how do i put the article title in ?

 

I kinda achieved this by getting meta title from the files head, but the page imidiatly started to low slowly :(

here's what i putted in the hidden's  field default value:

//&lt;code&gt; $pageURL = 'http'."://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; $xmlfile = file_get_contents ($pageURL);preg_match("|&lt;title&gt;(.*)&lt;/title&gt;|s", $xmlfile, $title);return $title[1];//&lt;/code&gt;

Please Log in or Create an account to join the conversation.

  • jorge mejia gallegos
  • jorge mejia gallegos's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 2 months ago #94459 by jorge mejia gallegos
Replied by jorge mejia gallegos on topic Insert k2 item title and author email in rsform pro module
Paste the code to item.php and substitute **---** with your information1) **YOUR_FORM_THEME** this inserts the form css file to the head, you could delete this line if not needed2) **YOUR_FORM_NUMBER** You will need the rsForm Pro Plugin for this to work3) setFormField( '**YOUR_FIELD_NAME**', '**YOUR_VALUE**' ); You can repeat this line if you wish to autopopulate more than one field example:setFormField( 'subject', '&lt;?php echo $this-&gt;item-&gt;title; ?&gt;' );&lt;!-- Contact Form --&gt;    &lt;div id="contactForm"&gt;     &lt;script type="text/javascript"&gt;     function setFormField( idRef, val ) {      if(!document.getElementById ) return;      var inputObj = document.getElementById( idRef );      if( inputObj ) {      inputObj.value = val;      }     }     &lt;/script&gt;       &lt;?php $document-&gt;addStyleSheet('components/com_rsform/assets/themes/**YOUR_FORM_THEME**/css/style.css'); ?&gt;    {rsform **YOUR_FORM_NUMBER**}     &lt;script type="text/javascript"&gt;     setFormField( '**YOUR_FIELD_NAME**', '**YOUR_VALUE**' );     &lt;/script&gt;&lt;/div&gt;&lt;!-- End Contact Form --&gt;

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum