Populate form with Job offer(s)

9 posts by 2 authors in: Forums > CMS Builder
Last Post: Yesterday at 2:12pm   (RSS)

By kovali - April 9

Hi,

On a page with job offers I want to create a link (for each job offer) to a new page with only a contactform where the first field should be automatically filled in with that corresponding job offer. How can I achieve this please?

Thx !!

By Dave - April 10

Hi kovali, 

The first step is to determine if your contact form accepts input from the URL.  Have a look at the code and see if you can pass in values like this:

myContactForm.php?name=Dave&email=user@example.com

If your contact form does that then you can create a link from your CMSB viewer files something like this:

<a href="myContactForm.php?name=<?php echo urlencode($record['name']) ?>&email=<?php echo urlencode($record['email']) ?>">

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By kovali - April 25

Hi Dave, 

I need a littlebit more help on this please...

I have this page with Jobs listing: https://metalprojects-overpelt.be/vacatures_test.php 

With this code:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  require_once "/home/metalpro/public_html/beheer/lib/viewer_functions.php";

  list($vacaturesRecords, $vacaturesMetaData) = getRecords(array(
    'tableName'   => 'vacatures',
	'where'       => "hide_listing != 0",
  ));

$numValue = getLastNumberInUrl('1');

?>
<?php foreach ($vacaturesRecords as $record): ?>
      
      <div class="page-inner">
         <div class="container">
            <div class="row">
               <div class="col-md-3">
              
                <div class="section-info">
                  <div class="title-hr"></div>
                  <div class="info-title">Vacature</div>
                </div>
                                
              </div>
              
              
              <div class="col-md-9">
              
              <div class="entry-content">
                <h3 class="entry-description"><?php echo $record['title'] ?></h3>
                 <p align="justify"><?php echo $record['content'] ?></p>
<p>» <a href="contact_vac.php?num=<?php echo urlencode($vacaturesRecord['num']) ?>">Reageren op deze vacature</a></p>
                                    
                </div>
                </div>
              </div>
            </div>
          </div>
          
          <?php endforeach ?>

I just don't know how to get the 'num' variable for each Job...

And the Job contact page: https://metalprojects-overpelt.be/contact_vac.php 

With this code:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  require_once "/home/metalpro/public_html/beheer/lib/viewer_functions.php";

  
// load record from 'panden'
  list($vacaturesRecords, $vacaturesMetaData) = getRecords(array(
    'tableName'   => 'vacatures',
    'where'       => whereRecordNumberInUrl(1),
	
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $vacaturesRecord = @$vacaturesRecords[0]; // get first record
  if (!$vacaturesRecord) { dieWith404("Record not found!"); } // show error message if no record found

?>
<div class="cfg-element-set" id="cfg-element-23-9-set" >
		<div class="cfg-element-content">
		<input name="cfg-element-23-9" type="text" class="cfg-type-text cfg-form-value " id="cfg-element-23-9" value="<?php echo $vacaturesRecord['title'] ?>"  />
		</div>
	</div>

As you can see my knowledge of PHP is weak, but I think this is just a matter of the correct code in these 2 pages...?

Please if you could help me out with this... much obliged!

Thanks!

By Dave - April 26

Hi Kovali, 

We have a utility function that shows you all the available values.  Try this: 

<?php showme($record); ?>

See if the value you want is in that list and then you can output it with: <?php echo $record['fieldname']; ?>

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By kovali - May 2

Hi Dave, thanks already.

I managed to do this before but from a Detailpage.php > contactform.php

Now that I'm working from a Listpage.php I'm stuck... 

Could you please help me out with an example code for this so I can understand and finalize this requirement for my client ? 

Thank you a thousand times!

Koen

By Dave - May 2

Hi Koen, 

So you're trying to create a link from the list page to the details page? 

Try adding the showme inside the foreach like this: 

<?php foreach ($vacaturesRecords as $record): ?>
    <?php showme($record); ?>

That will show you all the available fields, then typically you'd create a link with: 

<?php echo $record['_link']; ?> or <?php echo $record['num']; ?>

Give it a try and let me know how far you get.

Dave Edis - Senior Developer
interactivetools.com

By kovali - May 2

Sorry Dave, but no, I want to create a link from the List page (with many job offers) to a contact form where people can apply for the job... Not to a detail page (there is no detail page at all). So that the title of the job offer will automaticaly be filled in in the first field of the form when clicked on the link "apply for this job" on the List page. 

I'm sorry for not being clear enough. The code should be: List page > contact form

Thx! 

By kovali - Yesterday at 1:18pm

Hi Dave, could you please let me know if it is possible and if so how it's done? Taking the title of any item from a List page through a link that will put it in a contact form field??

Thx!! 

By Dave - Yesterday at 2:12pm

Hi Koen, 

Here's the code to add: 

contact_vac.php?num=<?php echo urlencode($vacaturesRecord['num'])?>&title=<?php echo urlencode($vacaturesRecord['title'])?>

And here it is in your earlier code:

<?php foreach ($vacaturesRecords as $record): ?>
      
      <div class="page-inner">
         <div class="container">
            <div class="row">
               <div class="col-md-3">
              
                <div class="section-info">
                  <div class="title-hr"></div>
                  <div class="info-title">Vacature</div>
                </div>
                                
              </div>
              
              
              <div class="col-md-9">
              
              <div class="entry-content">
                <h3 class="entry-description"><?php echo $record['title'] ?></h3>
                 <p align="justify"><?php echo $record['content'] ?></p>
<p>» <a href="contact_vac.php?num=<?php echo urlencode($vacaturesRecord['num'])?>&title=<?php echo urlencode($vacaturesRecord['title'])?>">Reageren op deze vacature</a></p>
                                    
                </div>
                </div>
              </div>
            </div>
          </div>
          
          <?php endforeach ?>

Let me know if that works for you.

Dave Edis - Senior Developer
interactivetools.com