ProcessWire - Job Template
Aus Wikizone
Beispiel Setting für Jobs mit strukturierten Daten
Beispiel von SPPS
Job Template
Felder
{
"job_addresscountry": {
"id": 191,
"name": "job_addresscountry",
"label": "Land",
"flags": 0,
"type": "FieldtypeText",
"textformatters": [
"TextformatterEntities"
],
"minlength": 0,
"maxlength": 2048,
"showCount": 0,
"size": 0,
"collapsed": 0,
"inputfieldClass": "",
"showIf": "",
"themeInputSize": "",
"themeInputWidth": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"themeBlank": "",
"columnWidth": 100,
"required": "",
"requiredAttr": "",
"requiredIf": "",
"stripTags": "",
"placeholder": "",
"pattern": ""
},
"job_addresslocality": {
"id": 188,
"name": "job_addresslocality",
"label": "Ort",
"flags": 0,
"type": "FieldtypeText",
"textformatters": [
"TextformatterEntities"
],
"minlength": 0,
"maxlength": 2048,
"showCount": 0,
"size": 0,
"collapsed": 0,
"inputfieldClass": "",
"showIf": "",
"themeInputSize": "",
"themeInputWidth": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"themeBlank": "",
"columnWidth": 100,
"required": "",
"requiredAttr": "",
"requiredIf": "",
"stripTags": "",
"placeholder": "",
"pattern": ""
},
"job_addressregion": {
"id": 189,
"name": "job_addressregion",
"label": "Job Region",
"flags": 0,
"type": "FieldtypeText",
"textformatters": [
"TextformatterEntities"
],
"minlength": 0,
"maxlength": 2048,
"showCount": 0,
"size": 0,
"collapsed": 0,
"inputfieldClass": "",
"showIf": "",
"themeInputSize": "",
"themeInputWidth": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"themeBlank": "",
"columnWidth": 100,
"required": "",
"requiredAttr": "",
"requiredIf": "",
"stripTags": "",
"placeholder": "",
"pattern": ""
},
"job_basesalary_maxvalue": {
"id": 185,
"name": "job_basesalary_maxvalue",
"label": "job_basesalary_maxvalue",
"flags": 0,
"type": "FieldtypeInteger",
"zeroNotEmpty": 0,
"columnWidth": 33,
"inputType": "text",
"size": 10,
"collapsed": 0,
"defaultValue": "",
"showIf": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"required": "",
"requiredIf": "",
"min": "",
"max": ""
},
"job_basesalary_minvalue": {
"id": 184,
"name": "job_basesalary_minvalue",
"label": "job_basesalary_minvalue",
"flags": 0,
"type": "FieldtypeInteger",
"zeroNotEmpty": 0,
"collapsed": 0,
"columnWidth": 33,
"inputType": "text",
"size": 10,
"defaultValue": "",
"showIf": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"required": "",
"requiredIf": "",
"min": "",
"max": ""
},
"job_basesalary_unittext": {
"id": 186,
"name": "job_basesalary_unittext",
"label": "Bezahlung pro",
"flags": 0,
"type": "FieldtypeOptions",
"inputfieldClass": "InputfieldSelect",
"collapsed": 0,
"columnWidth": 33,
"initValue": "",
"showIf": "",
"themeInputSize": "",
"themeInputWidth": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"required": "",
"requiredIf": "",
"defaultValue": "",
"export_options": {
"default": "1=MONTH|Monat\n2=YEAR|Jahr\n3=HOUR|Stunde\n4=WEEK|Woche\n5=DAY|Tag"
}
},
"job_dateposted": {
"id": 179,
"name": "job_dateposted",
"label": "Job Datum",
"flags": 0,
"type": "FieldtypeDatetime",
"collapsed": 0,
"inputType": "text",
"htmlType": "date",
"dateSelectFormat": "yMd",
"yearFrom": 1922,
"yearTo": 2042,
"yearLock": 0,
"datepicker": 3,
"timeInputSelect": 0,
"dateInputFormat": "Y-m-d",
"size": 25,
"columnWidth": 25,
"notes": "Datum des Postings",
"defaultToday": 1,
"dateOutputFormat": "",
"showIf": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"required": "",
"requiredAttr": "",
"requiredIf": "",
"dateMin": "",
"dateMax": "",
"timeStep": "",
"timeMin": "",
"timeMax": "",
"timeInputFormat": "",
"placeholder": "",
"yearRange": ""
},
"job_description": {
"id": 181,
"name": "job_description",
"label": "job_description",
"flags": 0,
"type": "FieldtypeTextareaLanguage",
"inputfieldClass": "InputfieldCKEditor",
"contentType": 1,
"minlength": 0,
"maxlength": 0,
"showCount": 0,
"rows": 5,
"textformatters": [
"TextformatterHannaCode"
],
"htmlOptions": [
2,
4,
16
],
"langBlankInherit": 0,
"collapsed": 0,
"toolbar": "Format, Styles, -, Bold, Italic, -, RemoveFormat\nNumberedList, BulletedList, -, Blockquote\nPWLink, Unlink, Anchor\nPWImage, Table, HorizontalRule, SpecialChar\nPasteText, PasteFromWord\nScayt, -, Sourcedialog\nJustifyCenter, JustifyLeft, JustifyRight",
"inlineMode": 0,
"useACF": 1,
"usePurifier": 1,
"formatTags": "p;h1;h2;h3;h4;h5;h6;pre;address",
"contentsCss": "/site/templates/modules/InputfieldCKEditor/contents.css",
"stylesSet": "customstyles:/site/templates/modules/InputfieldCKEditor/mystyles.js",
"extraPlugins": [
"pwimage",
"pwlink",
"sourcedialog"
],
"removePlugins": "image,magicline",
"showIf": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"columnWidth": 100,
"required": "",
"requiredAttr": "",
"requiredIf": "",
"imageFields": "",
"toggles": "",
"extraAllowedContent": "",
"contentsInlineCss": "",
"customOptions": "",
"plugin_sourcedialog": ""
},
"job_employmenttype": {
"id": 192,
"name": "job_employmenttype",
"label": "Art der Anstellung",
"flags": 0,
"type": "FieldtypeOptions",
"inputfieldClass": "InputfieldSelect",
"collapsed": 0,
"initValue": "",
"showIf": "",
"themeInputSize": "",
"themeInputWidth": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"columnWidth": 100,
"required": "",
"requiredIf": "",
"defaultValue": "",
"export_options": {
"default": "1=FULL_TIME|Vollzeit\n2=PART_TIME|Teilzeit\n3=CONTRACTOR|Vertrag\n4=TEMPORARY|Zeitarbeit\n5=INTERN|Internship (Trainee etc.)\n6=VOLUNTEER|Volontariat\n7=PER_DIEM|Per diem\n8=OTHER|Andere"
}
},
"job_link": {
"id": 178,
"name": "job_link",
"label": "Link zum Jobangebot",
"flags": 0,
"type": "FieldtypeURL",
"textformatters": [
"TextformatterEntities"
],
"noRelative": 0,
"allowIDN": 0,
"allowQuotes": 0,
"addRoot": 0,
"collapsed": 0,
"minlength": 0,
"maxlength": 1024,
"showCount": 0,
"size": 0,
"showIf": "",
"themeInputSize": "",
"themeInputWidth": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"themeBlank": "",
"columnWidth": 100,
"required": "",
"requiredAttr": "",
"requiredIf": "",
"placeholder": "",
"pattern": ""
},
"job_logo": {
"id": 183,
"name": "job_logo",
"label": "Logo",
"flags": 0,
"type": "FieldtypeImage",
"fileSchema": 270,
"textformatters": [
"TextformatterEntities"
],
"extensions": "gif jpg jpeg png",
"maxFiles": 0,
"outputFormat": 2,
"descriptionRows": 1,
"useTags": 0,
"gridMode": "grid",
"focusMode": "on",
"resizeServer": 0,
"clientQuality": 90,
"maxReject": "",
"dimensionsByAspectRatio": "",
"defaultValuePage": "",
"inputfieldClass": "InputfieldImage",
"notes": "optional",
"collapsed": 0,
"outputString": "",
"noLang": "",
"entityEncode": "",
"tagsList": "",
"showIf": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"columnWidth": 100,
"required": "",
"requiredIf": "",
"unzip": "",
"overwrite": "",
"maxWidth": "",
"maxHeight": "",
"maxSize": "",
"minWidth": "",
"minHeight": "",
"aspect_ratios": ""
},
"job_organizationname": {
"id": 193,
"name": "job_organizationname",
"label": "Name der Organisation",
"flags": 0,
"type": "FieldtypeOptions",
"inputfieldClass": "InputfieldSelect",
"collapsed": 0,
"initValue": "",
"showIf": "",
"themeInputSize": "",
"themeInputWidth": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"columnWidth": 100,
"required": "",
"requiredIf": "",
"defaultValue": "",
"export_options": {
"default": "1=intensiv|SPPS Karlsruhe Intensiv\n2=karlsruhe|SPPS Karlsruhe\n3=rastatt|SPPS Ötigheim/Rastatt\n4=pforzheim|SPPS Pforzheim\n5=rheinhausen|SPPS Rheinhausen-Oberhausen\n6=tagespflege|Tagespflege Etje"
}
},
"job_organizationname_old": {
"id": 182,
"name": "job_organizationname_old",
"label": "Name der Organisation",
"flags": 0,
"type": "FieldtypeText",
"collapsed": 0,
"minlength": 0,
"maxlength": 2048,
"showCount": 0,
"size": 0,
"textformatters": "",
"inputfieldClass": "",
"showIf": "",
"themeInputSize": "",
"themeInputWidth": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"themeBlank": "",
"columnWidth": 100,
"required": "",
"requiredAttr": "",
"requiredIf": "",
"stripTags": "",
"placeholder": "",
"pattern": ""
},
"job_postalcode": {
"id": 190,
"name": "job_postalcode",
"label": "PLZ",
"flags": 0,
"type": "FieldtypeText",
"textformatters": [
"TextformatterEntities"
],
"minlength": 0,
"maxlength": 2048,
"showCount": 0,
"size": 0,
"collapsed": 0,
"inputfieldClass": "",
"showIf": "",
"themeInputSize": "",
"themeInputWidth": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"themeBlank": "",
"columnWidth": 100,
"required": "",
"requiredAttr": "",
"requiredIf": "",
"stripTags": "",
"placeholder": "",
"pattern": ""
},
"job_streetaddress": {
"id": 187,
"name": "job_streetaddress",
"label": "Adresse",
"flags": 0,
"type": "FieldtypeText",
"textformatters": [
"TextformatterEntities"
],
"collapsed": 0,
"minlength": 0,
"maxlength": 2048,
"showCount": 0,
"size": 0,
"inputfieldClass": "",
"showIf": "",
"themeInputSize": "",
"themeInputWidth": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"themeBlank": "",
"columnWidth": 100,
"required": "",
"requiredAttr": "",
"requiredIf": "",
"stripTags": "",
"placeholder": "",
"pattern": ""
},
"job_validthrough": {
"id": 180,
"name": "job_validthrough",
"label": "Gültig bis",
"flags": 0,
"type": "FieldtypeDatetime",
"inputType": "text",
"htmlType": "date",
"dateSelectFormat": "yMd",
"yearFrom": 1922,
"yearTo": 2042,
"yearLock": 0,
"datepicker": 3,
"timeInputSelect": 0,
"dateInputFormat": "Y-m-d",
"size": 25,
"columnWidth": 25,
"collapsed": 0,
"dateOutputFormat": "",
"showIf": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"required": "",
"requiredAttr": "",
"requiredIf": "",
"dateMin": "",
"dateMax": "",
"timeStep": "",
"timeMin": "",
"timeMax": "",
"timeInputFormat": "",
"placeholder": "",
"yearRange": "",
"defaultToday": ""
}
}
Options für:
job_basesalary_unittext
1=MONTH|Monat 2=YEAR|Jahr 3=HOUR|Stunde 4=WEEK|Woche 5=DAY|Tag
job_employmenttype
1=FULL_TIME|Vollzeit 2=PART_TIME|Teilzeit 3=CONTRACTOR|Vertrag 4=TEMPORARY|Zeitarbeit 5=INTERN|Internship (Trainee etc.) 6=VOLUNTEER|Volontariat 7=PER_DIEM|Per diem 8=OTHER|Andere
job_organizationname
kann genutzt werden wenn man mehrere Organisationen hat
Job Fieldset Page
Das Feld fasst die anderen Felder in eines zusammen. So kann man sie einfacher handeln.
{
"job": {
"id": 177,
"name": "job",
"label": "Job",
"flags": 0,
"type": "FieldtypeFieldsetPage",
"notes": "Daten für ein Jobposting",
"icon": "wrench",
"template_id": 0,
"parent_id": 0,
"repeaterLoading": 2,
"repeaterMaxItems": 1,
"repeaterMinItems": 1,
"collapsed": 0,
"repeaterFields": [
"job_dateposted",
"job_validthrough",
"job_organizationname",
"job_description",
"job_basesalary_minvalue",
"job_basesalary_maxvalue",
"job_basesalary_unittext",
"job_streetaddress",
"job_postalcode",
"job_addresslocality",
"job_addressregion",
"job_addresscountry",
"job_employmenttype",
"job_link",
"job_logo"
],
"showIf": "",
"themeOffset": "",
"themeBorder": "",
"themeColor": "",
"columnWidth": 100,
"required": "",
"requiredIf": "",
"fieldContexts": {
"job_dateposted": {
"icon": "calendar",
"notes": "Datum des Postings. Wenn leer wird das Erstelldatum dieser Seite verwendet."
},
"job_validthrough": {
"icon": "calendar",
"notes": "Empfohlen. Unbefristet für manche Berufsgruppen erlaubt (z.B. Bedienungen)"
},
"job_organizationname": [],
"job_description": [],
"job_basesalary_minvalue": [],
"job_basesalary_maxvalue": [],
"job_basesalary_unittext": [],
"job_streetaddress": [],
"job_postalcode": [],
"job_addresslocality": [],
"job_addressregion": [],
"job_addresscountry": [],
"job_employmenttype": [],
"job_link": {
"notes": "Wenn leer wird diese Seite genutzt."
},
"job_logo": []
}
}
}
Templates Import
Import Daten (Zulässige Kind/Elternseiten von Hand nachtragen)
{
"job": {
"id": 53,
"name": "job",
"fieldgroups_id": "job",
"flags": 0,
"cache_time": 0,
"useRoles": 1,
"editRoles": [],
"addRoles": [],
"createRoles": [],
"rolesPermissions": [],
"noInherit": 0,
"childrenTemplatesID": 0,
"sortfield": "",
"noChildren": 1,
"noParents": "",
"childTemplates": [],
"parentTemplates": [
"jobs"
],
"allowPageNum": 0,
"allowChangeUser": 0,
"redirectLogin": 0,
"urlSegments": 0,
"https": 0,
"slashUrls": 1,
"slashPageNum": 0,
"slashUrlSegments": 0,
"altFilename": "",
"guestSearchable": 0,
"pageClass": "",
"childNameFormat": "",
"pageLabelField": "fa-user-circle-o title",
"noGlobal": 0,
"noMove": 0,
"noTrash": 0,
"noSettings": 0,
"noChangeTemplate": 0,
"noShortcut": 0,
"noUnpublish": 0,
"noLang": 0,
"compile": 3,
"nameContentTab": 0,
"noCacheGetVars": "",
"noCachePostVars": "",
"useCacheForUsers": 0,
"cacheExpire": 0,
"cacheExpirePages": [],
"cacheExpireSelector": "",
"label": "Stellenangebot",
"tags": "",
"titleNames": 0,
"noPrependTemplateFile": 0,
"noAppendTemplateFile": 0,
"prependFile": "",
"appendFile": "",
"pagefileSecure": 0,
"tabContent": "",
"tabChildren": "",
"nameLabel": "",
"contentType": "",
"errorAction": 0,
"connectedFieldID": null,
"ns": "ProcessWire",
"_exportMode": true,
"roles": [
"guest"
],
"fieldgroupFields": [
"title",
"layout_blocks",
"job"
],
"fieldgroupContexts": {
"title": [],
"layout_blocks": [],
"job": []
}
},
"jobs": {
"id": 55,
"name": "jobs",
"fieldgroups_id": "jobs",
"flags": 0,
"cache_time": 0,
"useRoles": 1,
"editRoles": [],
"addRoles": [],
"createRoles": [],
"rolesPermissions": [],
"noInherit": 0,
"childrenTemplatesID": 0,
"sortfield": "",
"noChildren": "",
"noParents": -1,
"childTemplates": [
"job"
],
"parentTemplates": [],
"allowPageNum": 1,
"allowChangeUser": 0,
"redirectLogin": 0,
"urlSegments": 0,
"https": 0,
"slashUrls": 1,
"slashPageNum": 0,
"slashUrlSegments": 0,
"altFilename": "",
"guestSearchable": 0,
"pageClass": "",
"childNameFormat": "",
"pageLabelField": "fa-users title",
"noGlobal": 0,
"noMove": 0,
"noTrash": 0,
"noSettings": 0,
"noChangeTemplate": 0,
"noShortcut": 0,
"noUnpublish": 0,
"noLang": 0,
"compile": 3,
"nameContentTab": 0,
"noCacheGetVars": "",
"noCachePostVars": "",
"useCacheForUsers": 0,
"cacheExpire": 0,
"cacheExpirePages": [],
"cacheExpireSelector": "",
"label": "Stellenangebote",
"tags": "",
"titleNames": 0,
"noPrependTemplateFile": 0,
"noAppendTemplateFile": 0,
"prependFile": "",
"appendFile": "",
"pagefileSecure": 0,
"tabContent": "",
"tabChildren": "",
"nameLabel": "",
"contentType": "",
"errorAction": 0,
"connectedFieldID": null,
"ns": "ProcessWire",
"_exportMode": true,
"roles": [
"guest"
],
"fieldgroupFields": [
"title",
"layout_blocks",
"images",
"files",
"menu"
],
"fieldgroupContexts": {
"title": [],
"layout_blocks": [],
"images": [],
"files": [],
"menu": []
}
}
}
Template Jobs
Todo besser als Layout-Block
// JOBLIST
$joblist = '';
$jobs = pages('template=job,sort=-published');
foreach ($jobs as $item) {
$joblist .= '<li class="joblist-item"><a href="'.$item->url.'">'.$item->title.' ('.$item->job->job_organizationname->title.')</a></div>';
}
$joblist = '<ul class="joblist">'.$joblist.'</ul>';
Template Job
Benötigt im Admin Bereich nur das job Feld. In diesem sind alle anderen benötigten Felder bereits enthalten.
<?php namespace ProcessWire;
include_once('includes/SchemaHelper.php');
$sh = new SchemaHelper;
$jsonld = $sh->jsonldJobPosting($page);
// BEWERBUNGSFORMULAR WENN GESÜNSCHT
$contact = $forms->render('bewerbung');
ob_start();
?>
<div class="container">
<div id="apply">
<h1><?=$page->title?></h1>
<div class="job-description">
<?=$page->job->job_description?>
</div>
<div class="">Arbeitgeber</div>
<?=$page->job->job_organizationname->title?><br>
<?=$page->link?>
</div>
<div class="font-heavy">Arbeitsort</div>
<?=$page->job->job_streetaddress?><br>
<?=$page->job->job_postalcode?> <?=$page->job->job_addresslocality?>
</div>
<?php if ($page->job->job_basesalary_minvalue && $page->job->job_basesalary_maxvalue && $page->job->job_basesalary_unittext): ?>
<div class="font-heavy">Vergütung</div>
<div><?=$page->job->job_basesalary_minvalue?>€ - <?=$page->job->job_basesalary_maxvalue?>€ <?=$page->job->job_basesalary_unittext->title?></div>
<?php elseif($page->job->job_basesalary_minvalue && $page->job->job_basesalary_unittext): ?>
<div class="font-heavy">Vergütung</div>
<div><?=$page->job->job_basesalary_minvalue?>€ <?=$page->unit->title?></div>
<?php endif ?>
<div class="font-heavy pt-20">Art der Anstellung</div>
<div class="pb-30"><?=$page->job->job_employmenttype->title?></div>
</div>
<!-- Bewerbungsmöglichkeit -->
<div id="apply-form" class="">
<h2>Bewerbung</h2>
<div><?= $contact ?></div>
</div>
<!-- job ldjson -->
<?=$jsonld?>
</div>
<?php
$content = ob_get_clean();
Bewerbungsformular
{
"required": false,
"columnWidth": 0,
"roles": {
"form-submit": [
"guest"
],
"form-list": [],
"form-edit": [],
"form-delete": [],
"entries-list": [],
"entries-edit": [],
"entries-delete": [],
"entries-page": [],
"entries-resend": []
},
"flags": 256,
"pluginActions": [],
"framework": "Uikit3",
"allowPreset": 0,
"skipSessionKey": 0,
"useCookies": 0,
"partialEntryDays": 14,
"spamEntryDays": 7,
"submitText": "Absenden",
"successMessage": "Vielen Dank - Ihre Bewerbung wurde versendet.",
"errorMessage": "Ein Fehler ist aufgetreten. Bitte überprüfen Sie Ihre Eingaben.",
"mobilePx": 0,
"frBasic_noLoad": [],
"frBasic_cssURL": "/site/modules/FormBuilder/frameworks/basic/main.css",
"frBasic_itemContent": [
"description",
"out",
"error",
"notes"
],
"spamFlags": 0,
"listFields": [],
"entryDays": 0,
"emailSubject": "Bewerbungsformular auf salus-klinik.de",
"responderSubject": "Auto-Response",
"saveFlags": 35,
"spamWords": [],
"honeypot": "name_1",
"emailTo": "post@stephanschlegel.de",
"frUikit3_noLoad": [
"framework",
"jquery",
"jqueryui"
],
"frUikit3_ukURL": "/site/modules/FormBuilder/frameworks/uikit3/",
"frUikit3_css": "uikit.min.css",
"frUikit3_horizontal": "0",
"frUikit3_inlineErrorBelow": "1",
"frUikit3_horizHeaderWidth": 30,
"frUikit3_buttonType": "primary",
"children": {
"name_1": {
"type": "Text",
"label": "Name",
"required": false,
"columnWidth": 0,
"collapsed": "0",
"minlength": 0,
"maxlength": 2048,
"showCount": "0",
"size": 0
},
"name_2": {
"type": "Text",
"label": "Name",
"required": 1,
"columnWidth": 0,
"collapsed": "0",
"minlength": 0,
"maxlength": 2048,
"showCount": "0",
"size": 0
},
"e_mail": {
"type": "Email",
"label": "E-Mail",
"required": 1,
"columnWidth": 0,
"collapsed": "0",
"minlength": 0,
"maxlength": 250,
"showCount": "0",
"size": 0
},
"telefon": {
"type": "Text",
"label": "Telefon",
"required": 1,
"columnWidth": 0,
"collapsed": "0",
"minlength": 0,
"maxlength": 2048,
"showCount": "0",
"size": 0
},
"bewerbungsunterlagen": {
"type": "FormBuilderFile",
"label": "Bewerbungsunterlagen",
"notes": "Maximal 3 Dateien á 5MB",
"required": false,
"columnWidth": 0,
"collapsed": "0",
"extensions": "pdf doc docx xls xlsx gif jpg jpeg png",
"maxFiles": 3,
"maxFileSize": 5242880
}
}
}
Funktionalität
SchemaHelper
Für Erzeugung der Strukturierten Daten
<?php namespace ProcessWire;
/**
* SchemaHelper
* Class for structured data
* V1.0
*/
// @todo outsource some of the nessecary types (i.e. place) in backend use
// fieldgroups for that maybe s.th. like $place = getFg('schema_place')
class SchemaHelper{
// Load the requested schema from the schemas directory and register the class
public function jsonldJobPosting ($p) {
$jsonld = array();
$sanitizer = wire('sanitizer');
//set unset fields (for not mandatory fields)
$p->job->job_validthrough = $p->job->job_validthrough ? : ''; // todo test
$jsonld["@context"] = "http://schema.org/";
$jsonld["@type"] = "JobPosting";
if($p->job->job_link) $jsonld["url"] = $p->job->job_link;
else $jsonld["url"] = $sanitizer->url($p->httpUrl);
$jsonld["datePosted"] = !empty($p->job->job_dateposted) ? date('Y-m-d', $p->job->getUnformatted('job_dateposted') ) : date('Y-m-d', strtotime($p->created));
$jsonld["validThrough"] = date('Y-m-d', $p->job->getUnformatted('job_validthrough') );
$jsonld["description"] = $sanitizer->textarea($p->job->job_description);
$jsonld['hiringOrganization'] = array(
"@type" => "Organization",
"name" => $sanitizer->text($p->job->job_organizationname->title),
"sameAs" => $sanitizer->url($p->job->job_link)
);
if($p->job->link2)$jsonld['hiringOrganization']['logo'] = $p->job->link2;
$jsonld['title'] = $sanitizer->text($p->title);
if($p->job->job_basesalary_minvalue && $p->job->job_basesalary_maxvalue && $p->job->job_basesalary_unittext){
$jsonld['baseSalary'] = array(
"@type" => "MonetaryAmount",
"currency" => "EUR",
"value" => array(
"@type" => "QuantitativeValue",
"minValue" => $sanitizer->float($p->job->job_basesalary_minvalue),
"maxValue" => $sanitizer->float($p->job->job_basesalary_maxvalue),
"unitText" => $sanitizer->text($p->job->job_basesalary_unittext->value)
)
);
}else if($p->job->job_basesalary_minvalue && $p->job->job_basesalary_unittext){
$jsonld['baseSalary'] = array(
"@type" => "MonetaryAmount",
"currency" => "EUR",
"value" => array(
"@type" => "QuantitativeValue",
"value" => $sanitizer->float($p->job->job_basesalary_minvalue),
"unitText" => $sanitizer->text($p->job->job_basesalary_unittext->value)
)
);
}
$jsonld['jobLocation'] = array(
"@type" => "Place",
"address" => array(
"@type" => "PostalAddress",
"streetAddress" => $sanitizer->text($p->job->job_streetaddress),
"addressLocality" => $sanitizer->text($p->job->job_addresslocality),
"addressRegion" => $sanitizer->text($p->job->job_addressregion),
"postalCode" => $sanitizer->text($p->job->job_postalcode),
"addressCountry" => $sanitizer->text($p->job->job_addresscountry),
)
);
// recommended properties
if($c = count($p->job->job_employmenttype)){
$types = array();
foreach($p->job->job_employmenttype as $type){
$types[] = $sanitizer->text($type->value);
}
//var_dump($c);
if($c > 1) $jsonld['employmentType'] = $types;
else $jsonld['employmentType'] = $types[0];
}
//$out .= '<script type="application/ld+json">' . json_encode($jsonld) . '</script>';
$out = '<script type="application/ld+json">' . json_encode($jsonld,JSON_PRETTY_PRINT) . '</script>';
return $out;
}
}