Get K2 Item Elements In RSFormPro Fields

There are very good reasons why one may need to collect data from a K2 page such as Item ID, Page Title, Page Alias, Page URL, Author, blah blah, in order to autofill fields within a RSFormPro form. Thanks to the excellent programming skills of the developers at RS Joomla, it's quite simple to achieve with Joomla's excellent framework hooks.

The code for each field output is entered in the Default Value field when creating the form field as shown in the image below.

Get the current page ID
//<code>
return JFactory::getApplication()->input->getInt('id');
//</code>
K2 Page ID
Invalid Input

Get the current page URL
//<code>
return JUri::current();
//</code>
Get K2 Page URL
Invalid Input

Get the current page title
//<code>
$db = JFactory::getDbo();
$db->setQuery( 
$db->getQuery(true)
->select( $db->quoteName('title') )
->from( $db->quoteName('#__k2_items') )
->where( $db->quoteName('id').'='.JFactory::getApplication()->input->getInt('id') )
);
return $db->loadResult();
//</code>
K2 Page Title
Invalid Input

 

 

rsform get value coding


Monday, 09 October 2017 19:31  |   262 views

 

Copyright © 2017 CMSEnergizer.com. All Rights Reserved.
This website is powered by the Joomla!©™ 3 Website Framework | File download and article manager component by K2 | Advanced Module Manager and Modules Anywhere by NoNumber Elements | Website hosting and development by WebsiteDons

CMSEnergizer.com is owned and operated by Emuzement Net Inc, 4532 West Kennedy Blvd. Ste 180 33609 Tampa, Florida USA