From b31908029a2d301856a7d66364c056e3055f2423 Mon Sep 17 00:00:00 2001 From: Bryan Pedini Date: Thu, 17 Jan 2019 00:40:15 +0100 Subject: [PATCH] Added templating, added sessions Added templating to the one page app, added and configured sessions to remember the last position and stored sessions for one day, even after browser close. --- index.php | 121 +++++++++++++++------------------------- tmpl/contact-form.phtml | 0 tmpl/description.phtml | 13 +++++ tmpl/home.phtml | 48 ++++++++++++++++ tmpl/ideas.phtml | 0 tmpl/projects.phtml | 0 6 files changed, 106 insertions(+), 76 deletions(-) create mode 100644 tmpl/contact-form.phtml create mode 100644 tmpl/description.phtml create mode 100644 tmpl/home.phtml create mode 100644 tmpl/ideas.phtml create mode 100644 tmpl/projects.phtml diff --git a/index.php b/index.php index 93a258f..d55bc1c 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,8 @@ 'Previous', 1 => 'Home', 2 => 'About myself', 3 => 'What I\'ve done so far', @@ -11,71 +14,22 @@ } else { $section = $_POST ['section']; + if ( $section == 0 ) { + if ( isset ( $_SESSION [ 'section' ] ) ) { + $section = $_SESSION [ 'section' ]; + } + else { + $section = 1; + } + } + $_SESSION [ 'section' ] = $section; $section_title = $sections [ $section ]; $sections_content = [ - 1 => - '
-
-
-
-
-
-

Bryan Joshua Pedini

- An eighteen years old guy from Italy, with just some great ideas -
-
-
-
-
- ', - 2 => - '
-
-
-
-
-
-

About Me

- This is what I do. -
-
-
-
-
', + 1 => file_get_contents ( 'tmpl/home.phtml' ), + 2 => file_get_contents ( 'tmpl/description.phtml' ), + 3 => file_get_contents ( 'tmpl/projects.phtml' ), + 4 => file_get_contents ( 'tmpl/ideas.phtml' ), + 5 => file_get_contents ( 'tmpl/contact-form.phtml' ), ]; $arr_res = [ 'status' => 200, @@ -101,6 +55,14 @@ +
+
diff --git a/tmpl/contact-form.phtml b/tmpl/contact-form.phtml new file mode 100644 index 0000000..e69de29 diff --git a/tmpl/description.phtml b/tmpl/description.phtml new file mode 100644 index 0000000..082d47d --- /dev/null +++ b/tmpl/description.phtml @@ -0,0 +1,13 @@ +
+
+
+
+
+
+

About Me

+ This is what I do. +
+
+
+
+
\ No newline at end of file diff --git a/tmpl/home.phtml b/tmpl/home.phtml new file mode 100644 index 0000000..a5d6634 --- /dev/null +++ b/tmpl/home.phtml @@ -0,0 +1,48 @@ +
+
+
+
+
+
+

Bryan Joshua Pedini

+ An eighteen years old guy from Italy, with just some great ideas +
+
+
+
+
+ \ No newline at end of file diff --git a/tmpl/ideas.phtml b/tmpl/ideas.phtml new file mode 100644 index 0000000..e69de29 diff --git a/tmpl/projects.phtml b/tmpl/projects.phtml new file mode 100644 index 0000000..e69de29