I have a jobs page on my website.
I followed the instructions here: https://docs.grabaperch.com/pe…two-page-list-and-detail/
I have a sub folder called opportunities. Within the sub folder I have two pages
index.php which shows all of the listings and contains the following code:
PHP
I then have a job.php that just displays a single job post that is clicked through from the index.php page. It contains the following code:
PHP
- <?php
- // create the form region
- perch_content_create('Apply For Job Form', [
- 'template' => 'forms/apply_for_job.html'
- ]);
- // get the job and the rendered template
- $result = perch_content_custom('Jobs', array(
- 'skip-template' => true,
- 'return-html' => true,
- 'page' => '/opportunities/index.php',
- 'template' => 'opportunities/job_detail.html',
- 'filter' => 'slug',
- 'match' => 'eq',
- 'value' => perch_get('s'),
- 'count' => 1,
- ));
- if(!isset($result[0])) {
- // no job found; respond with 404
- }
- $job = $result[0];
- $job_html = $result['html'];
- // get the job title
- $title = '';
- if(isset($job['jobTitle'])) {
- $title = $job['jobTitle'];
- }
- // page output starts here
- // output your <!doctype html>, <html>, <head>, <body> etc
- // output the rendered template
- echo $job_html;
- // pass the job title variable and output the form region
- PerchSystem::set_var('jobFormTitle', $title);
- perch_content_custom('Apply For Job Form');
- ?>
Also on this page I would like to contain the latest three other jobs in a sidebar.
I thought I would be able to use the code from the index.php page. So it would be like this:
PHP
But it doesn't display anything at all?
Could someone let me know where I'm going wrong please?