cjbeck71081 Posted September 15, 2008 Share Posted September 15, 2008 I am implementing a content management system that is customized. I would like the ability to add new pages to the CMS and I was wondering what the best practice was for creating new PHP documents and editing them. Secondly i was wondering how search engine friendly a completely CMS based site is with all of the <?include ?> codes in the actual code... do the search engines read that well? Quote Link to comment Share on other sites More sharing options...
Mchl Posted September 15, 2008 Share Posted September 15, 2008 1. Your CMS should store content in database, so there's no need to create new files, just get differetn content from DB 2. Do you see any PHP code, when you display source in your web browser? Quote Link to comment Share on other sites More sharing options...
cjbeck71081 Posted September 15, 2008 Author Share Posted September 15, 2008 No i dont, but I also wanted to give the client the ability to create new pages.... these would obviously need to be PHP files which pull data from the DB, but how to create them?? Quote Link to comment Share on other sites More sharing options...
ScotDiddle Posted September 15, 2008 Share Posted September 15, 2008 cjbeck71081, It's a matter of escaping those chars that will be present on the newly created php file. The following example is a sub-set from a working script... I couldn't wrap it in [ code ] / [ /code ] elements because this parser complained about the opening single-quotes before the closing $PHPCode[] = '?>' . " \n"; statements.. Hope this helps. Scot L. Diddle, Richmond VA <?php /** * * Define where to place our newly defined HZForm.php file... * * This is the form the user fill out, then submits for Smarty processing, and * subsequent email processing. * */ $HZForm_dir = $_SERVER['DOCUMENT_ROOT']; // Which form is the user dealing with ? $HZForm_FileName = 'HZForm.php'; $HZFormFile = $HZForm_dir . '/' . $HZForm_FileName; if (file_exists($HZFormFile)) { // Get rid of any previous HZForm.php File... It may be out of date. $deleteResults = unlink($HZFormFile); if (!$deleteResults) { $error = " ERROR: Could not delete previous version of HZForm.php file.<br /><br>"; $error .= " Please report this error to the IS Helpdesk. Ask for WebForms help for form: \"HAZSPILL\"<br /><br>"; echo $error; exit; } } /** * * Tack on those items that Smarty processing complains about * */ $debug1 = FALSE; // Display $_SESSION['POST'] vars... $debug2 = TRUE; // Revert to in-line JS for debugging. $PHPCode = array(); $PHPCode[] = '<?php' . "\n"; $PHPCode[] = "\n"; $PHPCode[] = "\n\t\$currentProgram = \$_SERVER['PHP_SELF']; \n"; $PHPCode[] = "\n"; $PHPCode[] = "\n\t\$currentProgramPieces = explode('/', \$currentProgram); \n"; $PHPCode[] = "\n"; $PHPCode[] = "\n\t\$_PHPSELF = \$currentProgramPieces[1]; \n"; $PHPCode[] = "\n"; $PHPCode[] = "\tif (!empty(\$_POST)) {" . "\n"; $PHPCode[] = "\t\t\$_SESSION['POST'] = array(); \n"; $PHPCode[] = "\t\tforeach(\$_POST as \$IDX=> \$DBCandidate) { \n"; $PHPCode[] = "\t\t\t\$_SESSION['POST'][\$IDX] = \$DBCandidate; \n"; $PHPCode[] = "\t\t}" . "\n"; if ($debug1) { // Just above... $PHPCode[] = "\t\t require_once('include/debugFunctions.php');" . "\n"; $PHPCode[] = "\t\t printArray(\$_POST, '\$_POST');" . "\n"; $PHPCode[] = "\t\t printArray(\$_SESSION['POST'], 'POST');" . "\n"; $PHPCode[] = "\n"; $PHPCode[] = "\t\t exit();" . "\n"; } $PHPCode[] = "\n"; $PHPCode[] = "\t\trequire('include/loadHZDB.php'); \n "; $PHPCode[] = "\n"; $PHPCode[] = "\t // exit(); \n"; $PHPCode[] = "\theader('Location: HZSmartyCall.php'); \n "; $PHPCode[] = "\texit(); \n"; $PHPCode[] = "\n"; $PHPCode[] = "\t}" . "\n"; $PHPCode[] = '?>' . " \n"; $headItems = array(); if ($debug2) { // Just above... $PHPCode[] = '<?php' . "\n"; $PHPCode[] = "\techo \"<script type='text/javascript'> \n\"; \n"; $PHPCode[] = "\n"; $PHPCode[] = "\trequire('javascript/HZScripts.js'); \n" . "\n"; $PHPCode[] = "\n"; $PHPCode[] = "\techo \"</script> \n\"; " . "\n"; $PHPCode[] = '?>' . " \n"; } else { $headItems[] = "\t <script type=\"text/javascript\" language=\"JavaScript\" src=\"javascript/HZScripts.js\"></script> \n"; } $headItems[] = "\t<link href=\"css/WebForms.css\" rel=\"stylesheet\" type=\"text/css\" ></link> \n"; $currentFormLines = $_SESSION['hzOut']; $hzLine = array(); $lineOut = 0; $next = FALSE; foreach($PHPCode as $PHPCodeIn) { $hzLine[$lineOut] = $PHPCodeIn; $lineOut++; } foreach($currentFormLines as $hzLineIn) { $stristrResult = stristr($hzLineIn, '<title>'); if ($next) { $next = FALSE; foreach($headItems as $headItemsIn) { $hzLine[$lineOut] = $headItemsIn; $lineOut++; } } else { if ($stristrResult) { $next = 'TRUE'; } $hzLine[$lineOut] = $hzLineIn; $lineOut++; } } $lines = count($hzLine); $fh = fopen($HZFormFile, 'w'); if (!$fh) { echo "ERROR: Could not write the HAZSPILL User Form... Please report this error to the HelpDesk."; exit; } for ($i=0; $i < $lines; $i++) { $stristrQuery = stristr($hzLine[$i], '<textarea'); if (!$stristrQuery) { $hzLine[$i] .= "\n"; } $success = fwrite($fh, $hzLine[$i]); if (!$success) { $errorOccured = TRUE; } } if (!$errorOccured) { // Now that we have written out the form, show it to the user. header('Location: ' . $HZForm_FileName ); exit; } else { $error = " ERROR: Could not write new version of \$_SESSION['hzOut'].php file.<br /><br>"; $error .= " Please report this error to the IS Helpdesk. Ask for WebForms help for form: \"HAZSPILL\"<br /><br>"; echo $error; exit; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.