doing php (please work)

This commit is contained in:
Richard Mikloš 2024-01-25 12:48:58 +01:00
parent e03f3b5e0c
commit 9e768198f6
3 changed files with 15 additions and 5 deletions

@ -82,16 +82,24 @@ if (isset($_SESSION['user_id'])) {
$page_regex = '/<!--PAGENAME=(.*?)-->/s'; $page_regex = '/<!--PAGENAME=(.*?)-->/s';
$page_style_regex = '/<!--PAGESTYLE=(.*?)-->/s';
if (preg_match($page_regex, $page_data, $matches)) { if (preg_match($page_regex, $page_data, $matches)) {
$page_name = $matches[1]; $page_name = $matches[1];
$page_data = preg_replace($page_regex, '', $page_data); $page_data = preg_replace($page_regex, '', $page_data);
} } else {
else{
$page_name = ucfirst($page); $page_name = ucfirst($page);
} }
$output = str_replace('<template name="page name">', $page_name, $output); if (preg_match($page_style_regex, $page_data, $style_matches)) {
$page_style = $style_matches[1];
$page_data = str_replace('<template name="page styling">', $page_style, $page_data);
} else {
$page_style = "/styles/pages/$page_name.css";
$page_data = str_replace('<template name="page styling">', $page_style, $page_data);
}
$output = str_replace('<template name="page name">', $page_style, $output);
$output = str_replace('<template name="page content">', $page_data, $output); $output = str_replace('<template name="page content">', $page_data, $output);
echo $output; echo $output;

@ -1,3 +1,5 @@
<!--PAGENAME=Hello, <template name="username">-->
<!--PAGESTYLE=/styles/pages/user/style.css-->
<header class="user-index-header"> <header class="user-index-header">
<div class="user-index-header-text" id="headerText"> <div class="user-index-header-text" id="headerText">
<h1 class="user-index-h1">Hello, <span class="outlined-text"><template name="username"></template></span>.</h1> <h1 class="user-index-h1">Hello, <span class="outlined-text"><template name="username"></template></span>.</h1>

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/remixicon/4.0.1/remixicon.min.css" integrity="sha512-dTsohxprpcruDm4sjU92K0/Gf1nTKVVskNHLOGMqxmokBSkfOAyCzYSB6+5Z9UlDafFRpy5xLhvpkOImeFbX6A==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/remixicon/4.0.1/remixicon.min.css" integrity="sha512-dTsohxprpcruDm4sjU92K0/Gf1nTKVVskNHLOGMqxmokBSkfOAyCzYSB6+5Z9UlDafFRpy5xLhvpkOImeFbX6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="/styles/global.css"> <link rel="stylesheet" href="/styles/global.css">
<link rel="stylesheet" href='/styles/pages/<template name="page name">.css'> <link rel="stylesheet" href='<template name="page styling">'>
<title><template name="page name"></title> <title><template name="page name"></title>
</head> </head>
<body> <body>