16
V 1.0 OE NIK, 2013 1 PHP+SQL 10. CRUD review CMS

V 1.0 OE NIK, 2013 1 PHP+SQL 10. CRUD review CMS

Embed Size (px)

Citation preview

V 1.0 OE NIK, 2013 1

PHP+SQL10.

CRUD reviewCMS

V 1.0 OE NIK, 2013 2

PHP+SQL10.

CRUD reviewCMS

V 1.0

Reading user input

V 1.0

It is done in a loop (to avoid preg_replace / PCRE)

Replacement

V 1.0

Creating <select> inputs

V 1.0

Genres + Songs

OE NIK, 2013 6

V 1.0

Structure of a CRUD module• Actions:

– MOD– EDIT– DEL– SHOW– LIST

• Every action modifies $output (or redirects)• Main CMS approach: this $output is not the full page!

OE NIK, 2013 7

V 1.0 OE NIK, 2013 8

PHP+SQL10.

CRUD reviewCMS

V 1.0

TYPICAL WEBPAGE STRUCTURE

9OE NIK, 2014

V 1.0

THE GOD OF <DIV>• Easier to design/change• Easier to separate the style and the content using CSS• By default a block-level element, but this can be changed• float: none, left, right• clear:both

10OE NIK, 2014

V 1.0

CMS basic requirements• mod_rewrite to create SEO URLs• For every page: ID, code, name, module, html, default

OE NIK, 2013 11

V 1.0

Songs module – modifications in the HTML• <form action='index.php?action=EDIT&id=[song_id]' method='POST'>

<form action='[page_code]?action=EDIT&id=[song_id]' method='POST'>

• Instead of http://localhost/dir/ index.php?action=EDIT&id=42 , the form will submit to http://localhost/dir/songs?action=EDIT&id=42

• We should change the same references in the PHP file too

OE NIK, 2013 12

V 1.0

Songs module – modifications in the PHP• $page should always contain the page code• Move import(), designer_replace(),

create_select_from_array(), addlink() to general.php• (Add isloggedin(), draw_menu() to general.php)

• Check for CMSMOD comments in the html and php files– Changed every addlink(“index.php?action=xxx”) code

to addlink(“{$page}?action=xxx”)– Changed every header(“location: index.php”) code to

header(“location: {$page}”)– $module_html="html/song_form.html";

OE NIK, 2013 13

V 1.0

CMS Tasks• Download 10_lcms_part.zip• Structure??? Files??? .htaccess???• We should implement the index.php ( CMS

organization) and sample.module.inc.php (login/logout)• Songs module: WORKS out-of-the-box

OE NIK, 2013 14

V 1.0 OE NIK, 2013 15

16OE NIK, 2013