mirror of
https://github.com/typemill/typemill.git
synced 2025-08-05 21:57:31 +02:00
V2.1.0 - New reference feature in meta tabs
This commit is contained in:
@@ -134,6 +134,44 @@ class ControllerWebFrontend extends Controller
|
||||
$metadata = $this->c->get('dispatcher')->dispatch(new OnMetaLoaded($metadata),'onMetaLoaded')->getData();
|
||||
|
||||
|
||||
# REFERENCE FEATURE
|
||||
if(isset($metadata['meta']['referencetype']) && $metadata['meta']['referencetype'] != 'disable')
|
||||
{
|
||||
$referenceurl = rtrim($urlinfo['baseurl'], '/') . '/' . trim($metadata['meta']['reference'], '/');
|
||||
|
||||
switch ($metadata['meta']['referencetype']) {
|
||||
case 'redirect301':
|
||||
return $response->withHeader('Location', $referenceurl)->withStatus(301);
|
||||
break;
|
||||
case 'redirect302':
|
||||
return $response->withHeader('Location', $referenceurl)->withStatus(302);
|
||||
break;
|
||||
case 'outlink':
|
||||
return $response->withHeader('Location', $metadata['meta']['reference'])->withStatus(301);
|
||||
break;
|
||||
case 'copy':
|
||||
$refpageinfo = $extendedNavigation[$metadata['meta']['reference']] ?? false;
|
||||
if(!$refpageinfo)
|
||||
{
|
||||
return $this->c->get('view')->render($response->withStatus(404), '404.twig', [
|
||||
'title' => 'Referenced page not found',
|
||||
'description' => 'We did not find the page that has been referenced. Please inform the website owner to fix it in meta reference.'
|
||||
]);
|
||||
}
|
||||
|
||||
$refKeyPathArray = explode(".", $refpageinfo['keyPath']);
|
||||
$refItem = $navigation->getItemWithKeyPath($draftNavigation, $refKeyPathArray);
|
||||
|
||||
# GET THE CONTENT FROM REFENCED PAGE
|
||||
$liveMarkdown = $content->getLiveMarkdown($refItem);
|
||||
$liveMarkdown = $this->c->get('dispatcher')->dispatch(new OnMarkdownLoaded($liveMarkdown), 'onMarkdownLoaded')->getData();
|
||||
$markdownArray = $content->markdownTextToArray($liveMarkdown);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# CHECK ACCESS RESTRICTIONS
|
||||
$restricted = $this->checkRestrictions($metadata['meta'], $username, $userrole);
|
||||
if($restricted)
|
||||
|
@@ -78,20 +78,23 @@ meta:
|
||||
hidden: true
|
||||
css: hidden
|
||||
pattern: '[0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
|
||||
# fieldsetreference:
|
||||
# type: fieldset
|
||||
# legend: Reference
|
||||
# fields:
|
||||
# reference:
|
||||
# type: text
|
||||
# label: Reference to page
|
||||
# maxlength: 60
|
||||
# referencetype:
|
||||
# type: radio
|
||||
# label: Type of reference
|
||||
# options:
|
||||
# copy: Copy (copy the content of the referenced page)
|
||||
# redirect: Redirect (redirect the user to the referenced page)
|
||||
fieldsetreference:
|
||||
type: fieldset
|
||||
legend: Reference
|
||||
fields:
|
||||
reference:
|
||||
type: text
|
||||
label: Reference to page
|
||||
maxlength: 200
|
||||
referencetype:
|
||||
type: radio
|
||||
label: Type of reference
|
||||
options:
|
||||
disable: Disable
|
||||
redirect301: PERMANENT REDIRECT (301) the user to the referenced internal page
|
||||
redirect302: TEMPORARY REDIRECT (302) the user to the referenced internal page
|
||||
copy: COPY the content of the referenced internal page
|
||||
outlink: LINK to an external page
|
||||
fieldsetvisibility:
|
||||
type: fieldset
|
||||
legend: Visibility
|
||||
|
Reference in New Issue
Block a user