Getting the page with RS Form Pro - Joomla</a></h1> </div> <div class="grid fw-wrap pb8 mb16 bb bc-black-075"> <div class="grid--cell ws-nowrap mr16 mb8" title="2016-01-12 19:07:53Z"> <span class="fc-light mr2">Asked</span> <time itemprop="dateCreated" datetime="2014-07-06T16:23:09.167" class="fromnow">Jul 06 '14 at 16:23</time> </div> <div class="grid--cell ws-nowrap mr16 mb8"> <span class="fc-light mr2">Active</span> <time class="fromnow" title="2014-07-10T16:53:19.187" datetime="2014-07-10T16:53:19.187">Jul 10 '14 at 16:53</a> </div> <div class="grid--cell ws-nowrap mb8" title="Viewed 1,082 times"> <span class="fc-light mr2">Viewed</span> 1,082 times </div> </div> <div id="mainbar" role="main" aria-label="questions and answers"> <div id="question" class="question" data-questionid="24597900" data-ownerid="3586610" data-score="2"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="24597900"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="2">2</div> <button class="js-bookmark-btn s-btn s-btn__unset c-pointer py4"> <svg aria-hidden="true" class="svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M6 1a2 2 0 00-2 2v14l5-4 5 4V3a2 2 0 00-2-2H6zm3.9 3.83h2.9l-2.35 1.7.9 2.77L9 7.59l-2.35 1.7.9-2.76-2.35-1.7h2.9L9 2.06l.9 2.77z"></path></svg> <div class="js-bookmark-count mt4" data-value=""></div> </button> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><p>I'm trying to get the page title inside my form so i can know from witch page the form was submitted. </p> <p>I have seen RS Form's tutorial here -> <a class="external-link" href="http://www.rsjoomla.com/support/documentation/view-article/369-get-the-page-title.html" rel="nofollow">http://www.rsjoomla.com/support/documentation/view-article/369-get-the-page-title.html</a></p> <p>This doesn't seem to work. what i was trying to do is creating a hidden filed and inserting his default value to following code:</p> <pre><code><?php $doc = JFactory::getDocument(); return $doc->getTitle(); ?> </code></pre> <p>Afterwards, i added the hidden field to the form layout and useradmin by the quick toggle of RS Form Options.</p> <p>What i get in the email received is only this: getTitle(); ?> and not the true pagetitle.</p> <p>Have i gone wrong somewhere? and if so - where? maybe there is another way to do that?</p></div> <div class="mt24 mb12"> <div class="post-taglist grid gs4 gsy fd-column"> <div class="grid ps-relative"> <a href="../../questions/tagged/php" class="post-tag js-gps-track" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/joomla" class="post-tag js-gps-track" title="show questions tagged 'joomla'" rel="tag">joomla</a> <a href="../../questions/tagged/rs" class="post-tag js-gps-track" title="show questions tagged 'rs'" rel="tag">rs</a> </div> </div> </div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature owner grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jul 06 '14 at 16:23">asked Jul 06 '14 at 16:23</time> <a href="../../users/3586610/danigoodw" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/3586610.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Danigoodw" /> </a> <div class="s-user-card--info"> <a href="../../users/3586610/danigoodw" class="s-user-card--link">Danigoodw</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">379</li> <li class="s-award-bling s-award-bling__silver" title="3 silver badges">3</li> <li class="s-award-bling s-award-bling__bronze" title="10 bronze badges">10</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> <div id="comments-24597900" class="comments js-comments-container bt bc-black-075 mt12 " data-post-id="24597900" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-38110968" class="comment js-comment " data-comment-id="38110968" data-comment-owner-id="747978" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <a name="comment38110968_24597900"></a> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">you could use javascript to get the <title> and propagate the hidden field at runtime – pathfinder Jul 06 '14 at 17:14

2 Answers2

1

How about getting the URL of the page, instead of the title. The advantage is that it's unique (pages can have duplicated titles). This PHP code in a hidden field did the trick for me in BreezingForms, I assume it'll work in RS Form too:

<?php $pageURL = 'http://'; $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; return $pageURL ?>

johanpw
  • 647
  • 1
  • 11
  • 30
1

From reading the RS Form instructions, it sounds like you should use //<code> instead of <?php ie

//<code>
$doc = JFactory::getDocument();
return $doc->getTitle();
//</code>

I assume anything within those tags is then filtered before the form is displayed so that it renders as php.

From your email response, it looks like it renders raw php as text.

RichardB
  • 2,615
  • 1
  • 11
  • 14