Page 1 of 1

Changing News Module URL & Passing Page Data To Form

Posted: Mon Jun 10, 2013 10:05 am
by govicinity
CMS Made Simple™ 1.11.7 “Genovesa”
CGExtensions 1.34
Products 2.19.5
FormBuilder 0.7.3
News 2.12.12

I have been tangling with the Products module, and whilst it is good, it doesn't quite do everything I want it to, I am setting up a job recruitment website, what I want to do is list jobs, wages, location, category, job description, set a sort order for the date the latest jobs.

I also want to be able to have 4 jobs listed in a summary (basically a latest jobs list) on the homepage which the Products module doesn't let me do (please advise if I am incorrect).

I am wondering if there is any way to change the news URL so instead of "http://www.mysite.com/news/foo.html I can have the URL "http://www.mysite.com/jobs/foo.html ?

I am also looking to have a form on each of the jobs listing pages so the viewer/applicant can basically apply for the job from that page, so I need the form subject field to autofill with the name of the job, is this possible?

Re: Changing News Module URL & Passing Page Data To Form

Posted: Mon Jun 10, 2013 11:42 am
by velden
About the form: read the help of the FormBuilder module. There is a line about setting a value of a field, from within the {FormBuilder} tag.

Re: Changing News Module URL & Passing Page Data To Form

Posted: Mon Jun 10, 2013 12:00 pm
by govicinity
Hi again Velden, thanks for the reply, I did have a read through that, but couldn't see how I could take the title of the news article i.e.

Code: Select all

{$entry->title|cms_escape:htmlall}
and pass that to the subject field of the formbuilder built form subject title so the form subject is auto-populated in the form on that page for the specific job.

Re: Changing News Module URL & Passing Page Data To Form

Posted: Mon Jun 10, 2013 12:08 pm
by velden

Code: Select all

Passing Default Values to Forms

Calguy added a nice feature, which is that you can pass default field values to your form via the module tag. This allows you to have the same form in multiple places, but with different default values. It may not work for more exotic field types, but for fields that have a single value, you can specify like:

{FormBuilder form='my_form' value_FIELDNAME='default_value'}

This will set the field with FIELDNAME to 'default_value'.

This can be problematic, as sometimes field names are unwieldy or contain characters that don't work well with Smarty. So there is an alternative like this:

{FormBuilder form='my_form' value_fldNUMBER='default_value'}

That uses field NUMBER, where NUMBER is the internal FormBuilder field id. You might wonder how you know what that id is. Simply go into the FormBuilder configuration tab, and check "Show Field IDs"
So that would become something like (NOT tested):

Code: Select all

{FormBuilder form='my_form' value_FIELDNAME=`$entry->title|cms_escape:htmlall`}
note the backticks around the variable!

Re: Changing News Module URL & Passing Page Data To Form

Posted: Thu Jun 20, 2013 2:26 pm
by govicinity
I have tried the

Code: Select all

{FormBuilder form='krb_job_form' value_fld31=`$entry->title|cms_escape:htmlall`}
option thanks Velden, the admin panel in templates doesn't like the ` character unfortunately.

Code: Select all

{FormBuilder form='krb_job_form' value_fld31='$entry->title|cms_escape:htmlall'}
Inserts "$entry->title|cms_escape:htmlall" into the correct field in the form, but obviously I need the Job Title not $entry->title|cms_escape:htmlall in the box.

I am now back to using the Products module which I have made do exactly what I want, but getting one of the Products fields value to auto populate the fld31 input area in the form is proving a little difficult, been scratching my head for a few days now, this is my last issue, so hopefully I'll get it sorted soon!

Re: Changing News Module URL & Passing Page Data To Form

Posted: Thu Jun 20, 2013 9:38 pm
by Jo Morg
{FormBuilder form='krb_job_form' value_fld31=$entry->title|cms_escape:htmlall} should work...

Re: Changing News Module URL & Passing Page Data To Form

Posted: Sat Jun 22, 2013 7:26 pm
by Rolf
Just used it, this works for me:

Code: Select all

{FormBuilder form='contact' value_fld31=$foo}

Re: Changing News Module URL & Passing Page Data To Form

Posted: Mon Jun 24, 2013 12:30 pm
by govicinity
Hi Rolf, many thanks for coming back to me on this.

OK, so if I have a custom field in the Products module, can you give me some direction on how I can assign $foo to that particular custom field? And then I'll be able to pass the Product's info directly to the forms field as you have instructed with:

Code: Select all

{FormBuilder form='krb_job_form' value_fld31=$foo}
Been searching the forums and search engines on how to do this for days now, and have been coming up blank.

Re: Changing News Module URL & Passing Page Data To Form

Posted: Mon Jun 24, 2013 12:37 pm
by Jo Morg
But... didn't this work?

Code: Select all

{FormBuilder form='krb_job_form' value_fld31=$entry->title|cms_escape:htmlall}
Or even

Code: Select all

{assign 'foo' $entry->title|cms_escape:htmlall}
{FormBuilder form='krb_job_form' value_fld31=$foo}

Re: Changing News Module URL & Passing Page Data To Form

Posted: Mon Jun 24, 2013 1:30 pm
by govicinity
Hi Jo, for some reason it doesn't seem to, I have tried it in all formats/variations I can, it just doesn't seem to pass it to field 31, looks like it should, but doesn't, copied and pasted all possible solutions here now, and drawing blanks.

This is my basic skeletal body content before I start to really flesh out the site:

Code: Select all

</__body>
{global_content name='header'}
{global_content name='header_page_image'}
{global_content name='menu'}
{* Start Content *}
<div>
<p class="breadcrumbs">{breadcrumbs root='home' delimiter='>'}</p>
<h1>{title}</h1>
{content}
{assign 'foo' $entry->title|cms_escape:htmlall}
{FormBuilder form='krb_job_form' value_fld31=$foo}
</div>
{* End Content *}
{global_content name='footer'}
<__body>
Can't see that I'm doing anything wrong.

Here's the main part of the form itself, in case I am actually losing the plot:

Code: Select all

<div class="required"><label for="fbrp__38">Name*</label><input type="text" name="m24656fbrp__38" value="" size="25" maxlength="80"   id="fbrp__38" /></div>
<div><label for="fbrp__31">Our Job Reference</label><input type="text" name="m24656fbrp__31" value="" size="10" maxlength="10"   id="fbrp__31" /></div>
<div class="required"><label for="fbrp__35">Address*</label><input type="text" name="m24656fbrp__35" value="" size="25" maxlength="128"  id="fbrp__35" /></div>
<div class="required"><label for="fbrp__34">Phone*</label><input type="text" name="m24656fbrp__34" value="" size="16" maxlength="16"   id="fbrp__34" /></div>
<div class="required"><label for="fbrp__32">Email*</label><input type="text" name="m24656fbrp__32" value="" size="25" maxlength="80"   id="fbrp__32" /></div>
<div><label for="fbrp__36">How can we help?</label><textarea name="m24656fbrp__36" cols="60" rows="5" class="cms_textarea" id="fbrp__36"></textarea></div>     				        	<div><label for="fbrp__39">Upload CV</label><input type="file" class="cms_browse" name="m24656fbrp__39" size="10" maxlength="255"  id="fbrp__39" />
 Max. Size: 3000kb Extensions: jpg, gif, jpeg, png, doc, docx, pdf, odt</div>
<div class="submit"><input class="cms_submit fbsubmit" name="m24656fbrp_submit" id="m24656fbrp_submit" value="Submit" type="submit"  /></div>
The name of the "Our reference field" is: {$our_job_reference} / {$fld_31}, so as far as I can see everything being done so far is correct.

Re: Changing News Module URL & Passing Page Data To Form

Posted: Mon Jun 24, 2013 2:28 pm
by Jo Morg
govicinity wrote:Can't see that I'm doing anything wrong.
Mmmm.... and where does the $entry->title comes from?
If not from a news template, inside a loop, $entry->title has no meaning...
This:

Code: Select all

{assign 'foo' $entry->title|cms_escape:htmlall}
{FormBuilder form='krb_job_form' value_fld31=$foo}
has to be inside a News template... probably a summary template and inside the foreach loop for the $entry->title variable to be in scope.

Re: Changing News Module URL & Passing Page Data To Form

Posted: Mon Jun 24, 2013 2:42 pm
by govicinity
Right - got you, I was originally using the news module but couldn't bend it to my needs, so moved back to the Products module, so it's my fault for not explaining this correctly.