PHP Blog using the Twig templating

Objective

The objective of this assignment is to use the techniques learned in class to create a PHP Blog using the Twig templating engine to create the page templates, a MySQL database for the data, and PHP and PDO to handle the logic.

This assignment will be completed and graded as a team (2 or 3 students). If you have not joined a team. Go to the People page and click on the “Group Project” tab. There will be a list of groups you can join.

Resources

Starter Kit

Attachment mtm6331-blog It will provide you will all the necessary files for completing the project. All these files can be found in the blog directory.

Use the included file to complete the requirements below.

To help you get started the following have already been done for you:

  1. The database connection has already been created, and an sql file has been placed in the db folder. You will need to create a database called mtm6331-blog on your local machine. (MAMP)
  2. Twig has been preinstalled and configured. The cache and templates folders have been created.
  3. Each PHP file has been connected to its companion Twig template.
  4. Each PHP file contains comments that provide hints on how to complete each task.

( The sql is already creating)

Blog Database

Here is a description of the tables and columns that can be found in the mtm6331-blog database.

There are two tables in the database, posts and categories. The relationship between the two is that each post can belong to ONE category, but a category can be found on multiple posts. This is relationship is maintained by the category_id column on the posts table.

Below is the column structure and description for each table:

posts

  • post_id: The primary key for the posts table
  • post_slug: A url friendly post identifier that must be unique
  • post_title: Holds the title of the post in plain text
  • post_date: The date and time a post was added to the database
  • post_excerpt: A short description of the post. INCLUDES HTML.
  • post_body: The main body of the post. INCLUDES HTML.
  • category_id: The foreign key to the categories table to indicate which category the post belongs.

categories

  • category_id: The primary key for the categories table
  • category_slug: A url friendly category identifier
  • category_name: The name of the category.

Below are a few additional resources that maybe helpful:

Requirements

To successfully complete this assignment your must complete the following:

Create a Homepage

Use the index.php file and the list.html.twig template to create a homepage for your blog. The homepage will list the 5 most recent posts. Each post display the Title, Date, and excerpt. The Title should be a link to the post page.

(This is where I left on) I already create this part but you can have a look just in case)

Create a Posts Page

Use the post.php file and the post.html.twig template to create a post page for your blog. The post page will display content of the requested post and should include the Title, Date, Category Name, and Body. The Category Name should link to the category page. NOTE: The category name and slug are stored in the categories table.

The post page should also have an “Edit” button. When clicked this button should go to the edit.php file with the requested post data populated in the form.

Create a Category Page

Use the category.php file and the list.html.twig template to create a category page for your blog. The category page will list all the posts for the requested category. Each post display the Title, Date, and excerpt. The Title should be a link to the post page.

Create a Edit Page

Use the edit.php file and the form.html.twig template to create a edit page for your blog. The edit page will display the edit form with requested post data populated in the form.

The form should submit the data using the ‘post’ method and should include the following fields:

  • Title (text box)
  • Slug (text box)
  • Category (select box)
  • Excerpt (textarea)
  • Body (texture)

When the form is submitted, the form data should be used to update the post in the poststable, and redirect to the post’s post page.

Create an Add Page

Use the add.php file and the form.html.twig template to create a add page for your blog. The add page will display an empty edit form. When the form is submitted, the form data should be used to add a new posts to the posts table and redirect to the post’s post page.

Create Site Header

Use the config.php file and the base.html.twig template to create a site header. The site header should include a the site title, site navigation that includes a list of all the categories, and a search form.

The site navigation should be dynamically build pulling the list of the categories from the database.

The search form should submit to the search.php file and the data using the ‘get’method. There should be single text box for the search query.

Create a Search Page

Use the search.php file and the list.html.twig template to create a search page for your blog. The search page will list any the posts whose title, body, or excerpt contain the search query. Each post display the Title, Date, and excerpt. The Title should be a link to the post page.

Create an Error Page

Use the error.php file, .htaccess, and the error.html.twig template to create a error page for your blog. The error page should be used for when a post or page can not be found. The error page should have a link to take the user back to the homepage.

Update the TEAM.md File

Use the TEAM.md file to list the members of your team (Full Names) and the role that each team member played to help complete the project.

Bonus Requirements

The following task can be completed to for additional points.

Add a Stylesheet

Use style.css or create your own stylesheet to add CSS to the blog. The styles should make the blog more visually appealing, follows the best practices for responsive design, and is optimized for the multiple screen sizes and devices

Add Friendly URLs

Use the .htaccess file to convert all the of the site links and navigation to support friendly URLs.

Submission

you will zip up the entire blog directory with your completed project. The zip file should contain all the PHP, Twig, CSS and JavaScript files needed for the project. NOTE: It is NOT necessary to include a database or .sql file.

The grading of the assignment will the follow the rubric below. Each member of the team will receive the same grade, UNLESS it is determined that a member of the team did not do his/her fair share of the work. IMPORTANT! If any part of the project contains ANY Syntax Errors OR otherwise will not load you will receive 0 points for the entire project.

Rubric

PHP Blog Rubric

PHP Blog Rubric
Criteria Ratings Pts
This criterion is linked to a Learning OutcomeHomepage

Use index.php to retrieve the 5 most recent posts from the database and use list.html.twig to display the Title, Date, and Excerpt for each post. The Title should link to the post page.

5.0 pts

Successfully retrieve the 5 most recent post from the database and display the Title, Date and Excerpt for each post.

3.0 pts

Successfully retrieve the 5 most recent posts, but failed to display ALL the required content for each post.

0.0 pts

Failed retrieve the 5 most recent posts from the database OR the project contained a syntax error or failed to load.

5.0 pts
This criterion is linked to a Learning OutcomePost Page: Retrieve Post Data

Use post.php to retrieve ALL the post data from the database including the category name for the desired post.

5.0 pts

Successfully, retrieved ALL the post data for the desired post.

3.0 pts

Successfully retrieved only some of the required data.

0.0 pts

Failed to retrieve post data from the database OR the project contained a syntax error or failed to load.

5.0 pts
This criterion is linked to a Learning OutcomePost Page: Display Post Data

Use the post.html.twig template to display the desired post’s Title, Date, Category Name, and Body. The category name should link to the category page. An edit button should be created and should link to the edit page.

5.0 pts

Successfully, displayed all the required content for the desired post.

3.0 pts

Displayed only some of the required content for the post.

0.0 pts

Failed to display the required content for the desired post OR the project contained a syntax error or failed to load.

5.0 pts
This criterion is linked to a Learning OutcomeCategory Page

Use category.php to retrieve all the posts that match the desired category. Use list.html.twig to display the Title, Date, and Excerpt for each post.

5.0 pts

Successfully retrieve all the posts that match the desired category and display the Title, Date and Excerpt for each post.

3.0 pts

Successfully retrieved all the posts for the desired category, but failed to display the required content for each post.

0.0 pts

Failed retrieve all the posts for the desired category OR the project contained a syntax error or failed to load.

5.0 pts
This criterion is linked to a Learning OutcomeEdit Page: Display Populated Edit Form

Use edit.php to retrieve the desired post’s data from the database. Use the form.html.twig template, to display the edit form populated with the post’s data.

5.0 pts

Successfully, retrieved ALL the post data for the desired post and populated the edit form with the data.

3.0 pts

Retrieve only some of the required data for the desired post OR populate the only some of the form with the post data.

0.0 pts

Failed to retrieve the desired post from the database OR failed to populate the form with the post’s data OR the project contained a syntax error or failed to load.

5.0 pts
This criterion is linked to a Learning OutcomeEdit Page: Update Post

Use edit.php to update the post data with the form data and redirect back to the post page.

5.0 pts

Successfully, updated the post data with the form data and redirected back to the post page.

3.0 pts

Successfully, updated the post data with the form data, but failed to redirect back to the post page.

0.0 pts

Failed to the update the post data with the form data OR the project contained a syntax error or failed to load.

5.0 pts
This criterion is linked to a Learning OutcomeAdd Page

Use the add.php and form.html.twig template to display a empty edit form. Use add.php to add a new post to the database and redirect to the post page for the new post.

5.0 pts

Successfully, add a new post to the database using the form data and redirected to the post page for the new post.

3.0 pts

Successfully, add the new post to the database, but failed to redirect to the post page for the new post.

0.0 pts

Failed to add a new post to the database OR the project contained a syntax error or failed to load.

5.0 pts
This criterion is linked to a Learning OutcomeSite Header

Use config.php and base.html.twig to create site header that appears on every page of the site. The site header should contain the site title / logo, a site navigation containing links to all the category pages, and a search form.

5.0 pts

Successfully, created the site header with a site title / logo, site navigation, and search form.

3.0 pts

Successfully, created the site header with the site navigation, but failed to add a site title / logo or search form.

0.0 pts

Failed to created the site header with site navigation containing links to all the category pages OR the project contained a syntax error or failed to load.

5.0 pts
This criterion is linked to a Learning OutcomeSearch Page

Use search.php to retrieve all the posts whose Title, Body, or Excerpt contains the search query. Use list.html.twig to display the Title, Date, and Excerpt for each post.

5.0 pts

Successfully, retrieve all the posts whose Title, Body, or Excerpt contain the search query and displayed the Title, Date, and Excerpt.

0.0 pts

Failed to retrieve all the posts OR the project contained a syntax error or failed to load.

5.0 pts
This criterion is linked to a Learning OutcomeError Page

Use error.php, the .htaccess file and the error.html.twig template to create a error page for when a Page or Post could not be found.

5.0 pts

Successfully, created the error page and redirected all traffic that attempts to view a page or post that does not exist to the error page.

3.0 pts

Successfully, created the error page, but failed to redirect all traffic that attempts to view a page or post that does not exist to the error page.

0.0 pts

Failed to create an error page OR the project contained a syntax error or failed to load.

5.0 pts
This criterion is linked to a Learning OutcomeBONUS: Stylesheet

Create a stylesheet for the blog. The styles should make the blog more visually appealing, follows the best practices for responsive design, and is optimized for the multiple screen sizes and devices

5.0 pts

Successfully, created a stylesheet that improves the visual appeal of the blog, followed the best practices of responsive design, and was optimized for multiple screen sizes and devices.

0.0 pts

Failed to created a stylesheet that improves the visual appeal of the blog, followed the best practices of responsive design, and was optimized for multiple screen sizes and devices.

5.0 pts
This criterion is linked to a Learning OutcomeBONUS: Friendly URLs

Use the .htaccess file to convert all the of the site links and navigation to support friendly URLs.

5.0 pts

Successfully, created support for the friendly URLs.

0.0 pts

Failed to created support for the friendly URLs.

5.0 pts
Total Points: 60.0
Order from us and get better grades. We are the service you have been looking for.