Pages within our Framework Categories within Framework Products within Framework ...
-
Upload
wesley-owen -
Category
Documents
-
view
221 -
download
0
description
Transcript of Pages within our Framework Categories within Framework Products within Framework ...
Lecture#04
Ouline
Pages within our Framework Categories within Framework Products within Framework Model-View-Controller description of
Page, category and products Routing Requests
Content TableFields Fields Type DescriptionId Int (Primary
Key, Auto Increment)
A reference to framework for content entity
Current_revision
Int Refer to current version of content type
Active Boolean Active or inactive to show userSecure Boolean Secure or insecure to show either logged in
user or notParent Int A reference to its parent content typeOrder Int A reference to the order of the content type
to build sitemap or menusAuthor Int Who created the first version of content
typeType Int A reference to type of content this entity isPath Varchar Search engine friendly path for the contentCreated
Tiemstamp When the entity is created
Pages within Framework
To enable pages in framework we need: A model-Connection to database and
represent data on page A controller- will look up the current page A template (view)- display data on page to
user With all above, we need some extra
information Menu and Sub menu options Breadcrumb generation
Pages within Framework-Model Model
Ability to connect to database Search for a page given by page name/path Represent data on the page If no page found, generate “Page not found”
error Can be achieved using a constructor
Pass page path as parameter Set values to properties if page found Set particular value if page not found
Pages within Framework-Model We need following methods for page
model isValid(): used by controller to lookup if
the page is valid or not? isActive(): used by controller to lookup if
the page is active or not? isSecure(): used by controller to check if
the page is secure or not? And accessible to user or not?
getProperties(): return the properties of the page to integrated with view
Pages within Framework-View
Page view should have following template pages Header- to have common header on most of
the pages Footer- to have common footer on most of
the pages Page- to display the page to user
We my have additional pages in template 404 Error: indicates page not found Login: logged in by user to access secure
pages Page Disable: show page is inactive
Pages within Framework-View
Header Template
It may also contain CSS, JavaScript, Icon etc information
Pages within Framework-View
Footer Template It may contain copyright info, about us,
terms and conditions etc. Page Template
In case of “Page not found” template
Pages within Framework-View We may have other templates in
framework Page Disable template Login Form template Signup Form template Shipping Address template Change password template Shopping Cart template And sooooooooooooooo on
Can be limited with limited requirements
Pages within Framework-Controller
Controller of pages needs to perform the following task Clean the path requested Pass path to page model If the page is valid, convert page
properties to tags to use in template, output the page view
If the page is invalid, display 404 page If the page is valid and secure, display
the page if user is logged in, else direct user to login page
Products within Framework We breakdown functionality into 3
areas Model- manage product data by update,
save, clone Controller- interpret users requests,
interface with model, interact with view to display data
Template- to display list of products to end user
Products within Framework-Model
Product model needs the following functionality: Lookup a product based on a product path Determine if a product exists or not,
based on said path Store product data Return product data as an array Return a Boolean value indicating if a
product is valid or not
Products within Framework-View
Product View
Products within Framework-Controller Product Controller needs the
following functionality Needs to communicate with controller Clean the path requested Pass product URL path to controller If a valid product URL, display it using
view If not a valid URL, display “product not
found” page
Categories within Framework Our categories functionality of framework
will be same as products model and controller with some minor difference Not as many tables are required to get the
category detail, content_version table is enough
Categories need to list products contained within them
We have to deal with child-parent categories structure
Categories within Framework-Model Categories Model
Is complex than other product and pages model because it deals with categories and sub categories
In First stage▪ Use subqueries, that will count no. of subcategories▪ Queries are then cached and its references are
passed to template or view to display products In 2nd Stage
▪ Adding some additional functions in controller about cached queries, if there are any subcategory
Categories within Framework-View Categories View
We need 3 types of templates to display categories to end user
Category template Subcategory template Products Template within category
Categories within Framework-View Categories View
Category template
Categories within Framework-View Categories View
Subcategory template
Categories within Framework-View Categories View
Products template
Categories within Framework-Controller Categories Controller
Communicate with Model to get categories If no category found, show “No Category
Found” page List categories and sub categories using view If no subcategory found, show “No
Subcategory Found” page List products within categories using views, if
any, else show “No Product in Category”
Some thoughts In our framework, so far, the models,
controllers and views of products, categories, pages have same format
Thy can be improved using inheritance in PHP
Common classes can be defined with common functionalities
Product view includes one photo of product Product view can be changed to mange
more photos of products
Routing products and categories First path of the URL should include
the area of site that user is trying to access http://domain/sitearea etc
We need to maintain a list of active controllers
If sitearea match with any active controller Include controller file, create controller
object, pass control to framework controller
Else shows 4o4 page error or “Page not found”
Routing products and categories We need a controller table to save
list of active controllers